summaryrefslogtreecommitdiffstats
path: root/spec/unit
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-11-24 18:20:40 -0600
committerLuke Kanies <luke@madstop.com>2007-11-24 18:20:40 -0600
commit7eb09abebb91a567b081a651fce179acfadfb7c0 (patch)
treee51b71ee063fd3855b3ddc89a50f237fb2e427e0 /spec/unit
parent525682bc66557788445dba0ce432095755df1cc5 (diff)
downloadpuppet-7eb09abebb91a567b081a651fce179acfadfb7c0.tar.gz
puppet-7eb09abebb91a567b081a651fce179acfadfb7c0.tar.xz
puppet-7eb09abebb91a567b081a651fce179acfadfb7c0.zip
Implementing the test for setting the Rails
log level.
Diffstat (limited to 'spec/unit')
-rwxr-xr-x[-rw-r--r--]spec/unit/rails.rb59
1 files changed, 41 insertions, 18 deletions
diff --git a/spec/unit/rails.rb b/spec/unit/rails.rb
index 426479fce..ad32cac86 100644..100755
--- a/spec/unit/rails.rb
+++ b/spec/unit/rails.rb
@@ -4,19 +4,38 @@ require File.dirname(__FILE__) + '/../spec_helper'
require 'puppet/rails'
describe Puppet::Rails, "when initializing any connection" do
+ confine Puppet.features.rails? => "Cannot test without ActiveRecord"
+
it "should use settings" do
Puppet.settings.expects(:use).with(:main, :rails, :puppetmasterd)
Puppet::Rails.connect
end
- it "should set up a logger" do
- ActiveRecord::Base.expects(:logger=)
+ it "should set up a logger with the appropriate Rails log file" do
+ logger = mock 'logger'
+ Logger.expects(:new).with(Puppet[:railslog]).returns(logger)
+ ActiveRecord::Base.expects(:logger=).with(logger)
Puppet::Rails.connect
end
- it "should set the log level"
+ it "should set the log level to whatever the value is in the settings" do
+ Puppet.settings.stubs(:use)
+ Puppet.settings.stubs(:value).with(:rails_loglevel).returns("debug")
+ Puppet.settings.stubs(:value).with(:railslog).returns("/my/file")
+ logger = mock 'logger'
+ Logger.stubs(:new).returns(logger)
+ ActiveRecord::Base.stubs(:logger).returns(logger)
+ logger.expects(:level=).with(Logger::DEBUG)
+
+ ActiveRecord::Base.stubs(:allow_concurrency=)
+ ActiveRecord::Base.stubs(:verify_active_connections!)
+ ActiveRecord::Base.stubs(:establish_connection)
+ Puppet::Rails.stubs(:database_arguments)
+
+ Puppet::Rails.connect
+ end
it "should set ActiveRecord::Base.allow_concurrency" do
ActiveRecord::Base.expects(:allow_concurrency=).with(true)
@@ -39,6 +58,8 @@ describe Puppet::Rails, "when initializing any connection" do
end
describe Puppet::Rails, "when initializing a sqlite3 connection" do
+ confine Puppet.features.rails? => "Cannot test without ActiveRecord"
+
it "should provide the adapter, log_level, and dbfile arguments" do
Puppet.settings.expects(:value).with(:dbadapter).returns("sqlite3")
Puppet.settings.expects(:value).with(:rails_loglevel).returns("testlevel")
@@ -53,14 +74,16 @@ describe Puppet::Rails, "when initializing a sqlite3 connection" do
end
describe Puppet::Rails, "when initializing a mysql or postgresql connection" do
+ confine Puppet.features.rails? => "Cannot test without ActiveRecord"
+
it "should provide the adapter, log_level, and host, username, password, and database arguments" do
- Puppet.settings.expects(:value).with(:dbadapter).returns("mysql")
- Puppet.settings.expects(:value).with(:rails_loglevel).returns("testlevel")
- Puppet.settings.expects(:value).with(:dbserver).returns("testserver")
- Puppet.settings.expects(:value).with(:dbuser).returns("testuser")
- Puppet.settings.expects(:value).with(:dbpassword).returns("testpassword")
- Puppet.settings.expects(:value).with(:dbname).returns("testname")
- Puppet.settings.expects(:value).with(:dbsocket).returns("")
+ Puppet.settings.stubs(:value).with(:dbadapter).returns("mysql")
+ Puppet.settings.stubs(:value).with(:rails_loglevel).returns("testlevel")
+ Puppet.settings.stubs(:value).with(:dbserver).returns("testserver")
+ Puppet.settings.stubs(:value).with(:dbuser).returns("testuser")
+ Puppet.settings.stubs(:value).with(:dbpassword).returns("testpassword")
+ Puppet.settings.stubs(:value).with(:dbname).returns("testname")
+ Puppet.settings.stubs(:value).with(:dbsocket).returns("")
Puppet::Rails.database_arguments.should == {
:adapter => "mysql",
@@ -73,13 +96,13 @@ describe Puppet::Rails, "when initializing a mysql or postgresql connection" do
end
it "should provide the adapter, log_level, and host, username, password, database, and socket arguments" do
- Puppet.settings.expects(:value).with(:dbadapter).returns("mysql")
- Puppet.settings.expects(:value).with(:rails_loglevel).returns("testlevel")
- Puppet.settings.expects(:value).with(:dbserver).returns("testserver")
- Puppet.settings.expects(:value).with(:dbuser).returns("testuser")
- Puppet.settings.expects(:value).with(:dbpassword).returns("testpassword")
- Puppet.settings.expects(:value).with(:dbname).returns("testname")
- Puppet.settings.expects(:value).with(:dbsocket).returns("testsocket")
+ Puppet.settings.stubs(:value).with(:dbadapter).returns("mysql")
+ Puppet.settings.stubs(:value).with(:rails_loglevel).returns("testlevel")
+ Puppet.settings.stubs(:value).with(:dbserver).returns("testserver")
+ Puppet.settings.stubs(:value).with(:dbuser).returns("testuser")
+ Puppet.settings.stubs(:value).with(:dbpassword).returns("testpassword")
+ Puppet.settings.stubs(:value).with(:dbname).returns("testname")
+ Puppet.settings.stubs(:value).with(:dbsocket).returns("testsocket")
Puppet::Rails.database_arguments.should == {
:adapter => "mysql",
@@ -91,4 +114,4 @@ describe Puppet::Rails, "when initializing a mysql or postgresql connection" do
:socket => "testsocket"
}
end
-end \ No newline at end of file
+end