summaryrefslogtreecommitdiffstats
path: root/spec/unit
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit')
-rw-r--r--spec/unit/rails.rb61
1 files changed, 35 insertions, 26 deletions
diff --git a/spec/unit/rails.rb b/spec/unit/rails.rb
index 41fc3a11e..76fb311c5 100644
--- a/spec/unit/rails.rb
+++ b/spec/unit/rails.rb
@@ -5,43 +5,52 @@ require 'puppet/rails'
describe Puppet::Rails, " when using sqlite3" do
setup do
- @old_adapter = Puppet[:dbadapter]
- @old_dbsocket = Puppet[:dbsocket]
-
- Puppet[:dbadapter] = "sqlite3"
- end
-
- teardown do
- Puppet[:dbadapter] = @old_adapter
- Puppet[:dbsocket] = @old_dbsocket
+ expectation_setup
end
it "should ignore the database socket argument" do
- Puppet[:dbsocket] = "blah"
Puppet::Rails.database_arguments[:socket].should be_nil
end
+
+ private
+ def expectation_setup(extra = {})
+ arguments_and_results = {
+ :dbadapter => "sqlite3",
+ :rails_loglevel => "testlevel",
+ :dblocation => "testlocation"
+ }.merge(extra)
+
+ arguments_and_results.each do |argument, result|
+ Puppet.settings.expects(:value).with(argument).returns(result)
+ end
+ end
end
describe Puppet::Rails, " when not using sqlite3" do
- setup do
- @old_adapter = Puppet[:dbadapter]
- @old_dbsocket = Puppet[:dbsocket]
-
- Puppet[:dbadapter] = "mysql"
- end
-
- teardown do
- Puppet[:dbadapter] = @old_adapter
- Puppet[:dbsocket] = @old_dbsocket
- end
-
- it "should set the dbsocket argument if not empty " do
- Puppet[:dbsocket] = "blah"
- Puppet::Rails.database_arguments[:socket].should == "blah"
+ it "should set the dbsocket argument if not empty" do
+ expectation_setup
+ Puppet::Rails.database_arguments[:socket].should == "testsocket"
end
it "should not set the dbsocket argument if empty" do
- Puppet[:dbsocket] = ""
+ expectation_setup(:dbsocket => "")
Puppet::Rails.database_arguments[:socket].should be_nil
end
+
+ private
+ def expectation_setup(extra = {})
+ arguments_and_results = {
+ :dbadapter => "mysql",
+ :rails_loglevel => "testlevel",
+ :dbserver => "testserver",
+ :dbuser => "testuser",
+ :dbpassword => "testpassword",
+ :dbname => "testdb",
+ :dbsocket => "testsocket"
+ }.merge(extra)
+
+ arguments_and_results.each do |argument, result|
+ Puppet.settings.expects(:value).with(argument).returns(result)
+ end
+ end
end \ No newline at end of file