spec/wackamole/models/control_spec.rb in wackamole-0.0.9 vs spec/wackamole/models/control_spec.rb in wackamole-0.1.2
- old
+ new
@@ -5,58 +5,52 @@
before( :all ) do
Wackamole::Control.reset!
end
it "should raise an error if not correctly initialized" do
- lambda{ Wackamole::Control.connection }.should raise_error( /You must call init_config/ )
+ lambda{ Wackamole::Control.connection( "Fred" ) }.should raise_error( /You must call init_config/ )
end
it "should raise an error if invalid config file" do
config_file = File.join(File.dirname(__FILE__), %w[.. .. config blee.yml])
lambda {
- Wackamole::Control.init_config( config_file, 'test' )
+ Wackamole::Control.init_config( config_file )
}.should raise_error( /Hoy! An error occur loading the config file `#{config_file} -- No such file or directory/ )
end
-
- it "should raise an error if a bogus env is requested" do
- config_file = File.join(File.dirname(__FILE__), %w[.. .. config test.yml])
- lambda {
- Wackamole::Control.init_config( config_file, 'production' )
- }.should raise_error( /Hoy! An error occur loading the config file `#{config_file} -- Invalid environment `production/ )
- end
-
+
it "should raise an error if invalid config file content" do
config_file = File.join(File.dirname(__FILE__), %w[.. .. config bogus_test.yml])
lambda {
- Wackamole::Control.init_config( config_file, 'test' )
- }.should raise_error( /Hoy! An error occur loading the config file `#{config_file} -- Unable to find host in -/ )
+ Wackamole::Control.init_config( config_file )
+ }.should raise_error( /Hoy! An error occur loading the config file `#{config_file} -- Unable to find zones definition/ )
end
end
describe 'connection' do
before :all do
Wackamole::Control.reset!
- Wackamole::Control.init_config( File.join(File.dirname(__FILE__), %w[.. .. config test.yml]), 'test' )
- Wackamole::Control.connection.should_not be_nil
+ Wackamole::Control.init_config( File.join(File.dirname(__FILE__), %w[.. .. config test.yml]) )
+ Wackamole::Control.connection( 'test' ).should_not be_nil
end
describe "#collection" do
it "should find a collection correctly" do
- cltn = Wackamole::Control.collection( 'features', "mole_app1_test_mdb" )
+ Wackamole::Control.current_db( 'test', 'app1', 'test' )
+ cltn = Wackamole::Control.collection( 'features' )
cltn.count.should == 6
feature = cltn.find_one()
feature['app'].should == "app1"
feature['env'].should == "test"
- feature['did'].should == Time.now.utc.to_date_id.to_s
+ feature['did'].should == Time.now.to_date_id.to_s
feature['ctx'].should match( /\// )
end
end
describe "mole databases" do
it "should correctly identify mole dbs" do
# gen_bogus_dbs
- mole_dbs = Wackamole::Control.mole_databases
+ mole_dbs = Wackamole::Control.mole_databases( 'test' )
mole_dbs.should have(2).items
end
it "should extra app/env correctly" do
Wackamole::Control.extract_app_info( "mole_fred_development_mdb" ).should == ['fred', 'development']
@@ -68,31 +62,31 @@
}.should raise_error( /Invalid mole db specification mole_fred_mdb/ )
end
it "should connect to a mole databases correctly" do
%w[app1 app2].each do |app|
- Wackamole::Control.db( "mole_#{app}_test_mdb" )
+ Wackamole::Control.current_db( "test", app, "test", true )
feature = Wackamole::Control.collection( 'features' ).find_one()
feature['app'].should == app
feature['env'].should == "test"
end
end
- it "should switch mole dbs correctly" do
- %w[app1 app2].each do |app|
- Wackamole::Control.switch_mole_db!( app, "test" )
- feature = Wackamole::Control.collection( 'features' ).find_one()
- feature['app'].should == app
- feature['env'].should == "test"
- end
- end
+ # it "should switch mole dbs correctly" do
+ # %w[app1 app2].each do |app|
+ # Wackamole::Control.switch_mole_db!( app, "test" )
+ # feature = Wackamole::Control.collection( 'features' ).find_one()
+ # feature['app'].should == app
+ # feature['env'].should == "test"
+ # end
+ # end
- it "should fail to switch if there is no mole db" do
- lambda{ Wackamole::Control.switch_mole_db!( "blee", "test" ) }.should raise_error( /Invalid mole database mole_blee_test_mdb/ )
- end
-
- it "should fail to switch for an invalid mole db" do
- lambda{ Wackamole::Control.switch_mole_db!( "zorg", "missing" ) }.should raise_error( /Invalid mole database mole_zorg_missing_mdb/ )
- end
+ # it "should fail to switch if there is no mole db" do
+ # lambda{ Wackamole::Control.switch_mole_db!( "blee", "test" ) }.should raise_error( /Invalid mole database mole_blee_test_mdb/ )
+ # end
+ #
+ # it "should fail to switch for an invalid mole db" do
+ # lambda{ Wackamole::Control.switch_mole_db!( "zorg", "missing" ) }.should raise_error( /Invalid mole database mole_zorg_missing_mdb/ )
+ # end
end
end
end
\ No newline at end of file