spec/settings_spec.rb in bret-watircraft-0.4.3 vs spec/settings_spec.rb in bret-watircraft-0.4.4

- old
+ new

@@ -11,23 +11,23 @@ end it "should use environment variable for browser settings" do Taza::Settings.stubs(:path).returns("spec/sandbox") ENV['BROWSER'] = 'foo' - Taza::Settings.config('SiteName')[:browser].should eql(:foo) + Taza::Settings.config('SiteName')[:browser].should eql('foo') end it "should use environment variable for driver settings" do Taza::Settings.stubs(:path).returns("spec/sandbox") ENV['DRIVER'] = 'bar' - Taza::Settings.config('SiteName')[:driver].should eql(:bar) + Taza::Settings.config('SiteName')[:driver].should eql('bar') end it "should provide default values if no config file or environment settings provided" do Taza::Settings.stubs(:path).returns("spec/sandbox") - Taza::Settings.config('SiteName')[:driver].should eql(:watir) - Taza::Settings.config('SiteName')[:browser].should eql(:firefox) + Taza::Settings.config('SiteName')[:driver].should eql('watir') + Taza::Settings.config('SiteName')[:browser].should eql('firefox') end it "should be able to load the site yml" do Taza::Settings.stubs(:path).returns("spec/sandbox") Taza::Settings.config("SiteName")[:url].should eql('http://google.com') @@ -39,25 +39,25 @@ Taza::Settings.config("SiteName")[:url].should eql('http://clownshoes.com') end it "should use the config file's variable for browser settings if no environment variable is set" do Taza::Settings.stubs(:path).returns("spec/sandbox") - Taza::Settings.expects(:config_file).returns({:browser => :fu}) - Taza::Settings.config('SiteName')[:browser].should eql(:fu) + Taza::Settings.expects(:config_file).returns({:browser => 'fu'}) + Taza::Settings.config('SiteName')[:browser].should eql('fu') end it "should use the config file's variable for driver settings if no environment variable is set" do Taza::Settings.stubs(:path).returns("spec/sandbox") - Taza::Settings.stubs(:config_file).returns({:driver => :fun}) - Taza::Settings.config('SiteName')[:driver].should eql(:fun) + Taza::Settings.stubs(:config_file).returns({:driver => 'fun'}) + Taza::Settings.config('SiteName')[:driver].should eql('fun') end it "should use the ENV variables if specified instead of config files" do ENV['BROWSER'] = 'opera' - Taza::Settings.expects(:config_file).returns({:browser => :fu}) + Taza::Settings.expects(:config_file).returns({:browser => 'fu'}) Taza::Settings.stubs(:path).returns("spec/sandbox") - Taza::Settings.config('SiteName')[:browser].should eql(:opera) + Taza::Settings.config('SiteName')[:browser].should eql('opera') end it "should use the correct config file" do Taza::Settings.stubs(:path).returns("spec/sandbox") Taza::Settings.stubs(:config_file_path).returns('spec/sandbox/config.yml') @@ -79,25 +79,32 @@ end it "setting keys can be specified as strings (i.e. without a colon) in the config file" do Taza::Settings.stubs(:config_file_path).returns("spec/sandbox/config/simpler.yml") Taza::Settings.stubs(:path).returns("spec/sandbox") - Taza::Settings.config('SiteName')[:browser].should eql(:opera) + Taza::Settings.config('SiteName')[:browser].should eql('opera') end it "setting keys can be specified as strings (i.e. without a colon) in the config file" do Taza::Settings.stubs(:path).returns("spec/sandbox") Taza::Settings.stubs(:environment_file).returns('config/simpler_site.yml') Taza::Settings.config('SimplerSite')[:url].should eql('http://makezine.com') end it "should be able to convert string keys to symbol keys" do - result = Taza::Settings.convert_string_keys_to_symbols 'browser' => :foo - result.should == {:browser => :foo} + result = Taza::Settings.convert_string_keys_to_symbols 'browser' => 'foo' + result.should == {:browser => 'foo'} end it "should provide an empty hash when the config file doesn't exist" do Taza::Settings.stubs(:config_file_path).returns('spec/sandbox/config/no_such_file.yml') Taza::Settings.config_file.should == {} + end + + it "should parse true/false values" do + Taza::Settings.to_bool('true').should == true + Taza::Settings.to_bool('True').should == true + Taza::Settings.to_bool('false').should == false + Taza::Settings.to_bool(nil).should == false end end