diff options
author | Luke Kanies <luke@madstop.com> | 2007-11-24 18:06:29 -0600 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2007-11-24 18:06:29 -0600 |
commit | 525682bc66557788445dba0ce432095755df1cc5 (patch) | |
tree | 68d09b63793ce272a5df2cf3185590a905013ce5 /spec/unit | |
parent | 676efa77b2481081deee35c19ed42b66489e0f70 (diff) | |
parent | 7f1b2d658d42bd7fcbd38da157f5e9eedf44fbf2 (diff) | |
download | puppet-525682bc66557788445dba0ce432095755df1cc5.tar.gz puppet-525682bc66557788445dba0ce432095755df1cc5.tar.xz puppet-525682bc66557788445dba0ce432095755df1cc5.zip |
Merge commit 'danp/rails_socket_and_tests'
Diffstat (limited to 'spec/unit')
-rw-r--r-- | spec/unit/rails.rb | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/spec/unit/rails.rb b/spec/unit/rails.rb new file mode 100644 index 000000000..426479fce --- /dev/null +++ b/spec/unit/rails.rb @@ -0,0 +1,94 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../spec_helper' +require 'puppet/rails' + +describe Puppet::Rails, "when initializing any connection" do + 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=) + + Puppet::Rails.connect + end + + it "should set the log level" + + it "should set ActiveRecord::Base.allow_concurrency" do + ActiveRecord::Base.expects(:allow_concurrency=).with(true) + + Puppet::Rails.connect + end + + it "should call ActiveRecord::Base.verify_active_connections!" do + ActiveRecord::Base.expects(:verify_active_connections!) + + Puppet::Rails.connect + end + + it "should call ActiveRecord::Base.establish_connection with database_arguments" do + Puppet::Rails.expects(:database_arguments) + ActiveRecord::Base.expects(:establish_connection) + + Puppet::Rails.connect + end +end + +describe Puppet::Rails, "when initializing a sqlite3 connection" do + 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") + Puppet.settings.expects(:value).with(:dblocation).returns("testlocation") + + Puppet::Rails.database_arguments.should == { + :adapter => "sqlite3", + :log_level => "testlevel", + :dbfile => "testlocation" + } + end +end + +describe Puppet::Rails, "when initializing a mysql or postgresql connection" do + 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::Rails.database_arguments.should == { + :adapter => "mysql", + :log_level => "testlevel", + :host => "testserver", + :username => "testuser", + :password => "testpassword", + :database => "testname" + } + 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::Rails.database_arguments.should == { + :adapter => "mysql", + :log_level => "testlevel", + :host => "testserver", + :username => "testuser", + :password => "testpassword", + :database => "testname", + :socket => "testsocket" + } + end +end
\ No newline at end of file |