diff options
author | Dan Peterson <dpeterson@spark.dpiddy.local> | 2007-11-23 22:12:15 -0700 |
---|---|---|
committer | Dan Peterson <dpeterson@spark.dpiddy.local> | 2007-11-23 22:12:15 -0700 |
commit | c19d08a37632410b1835350dfaacedde974b1003 (patch) | |
tree | d8f56b050c01e92f2063938c9b6cef4b5be3e46a /spec/unit | |
parent | e69e0c32031e297ae62dd822a925b38e93bdd84f (diff) | |
download | puppet-c19d08a37632410b1835350dfaacedde974b1003.tar.gz puppet-c19d08a37632410b1835350dfaacedde974b1003.tar.xz puppet-c19d08a37632410b1835350dfaacedde974b1003.zip |
mock all use of Puppet[] in Puppet::Rails.database_arguments
Diffstat (limited to 'spec/unit')
-rw-r--r-- | spec/unit/rails.rb | 61 |
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 |