Skip to content

Commit

Permalink
updated path to original directory, added TODO to move skeleton project
Browse files Browse the repository at this point in the history
  • Loading branch information
orieken committed Mar 24, 2014
1 parent 5082109 commit a9e832e
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions spec/taza/settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require 'taza/site'

describe Taza::Settings do

#TODO: we need to clean these tests up some lots of repetition and move skeleton project to tmp dir
before :all do
@site_name = 'SiteName'
end
Expand All @@ -18,55 +18,55 @@
end

it "should use environment variable for browser settings" do
Taza::Settings.stubs(:path).returns("spec/sandbox")
Taza::Settings.stubs(:path).returns("#{@original_directory}/spec/sandbox")
ENV['BROWSER'] = 'foo'
Taza::Settings.config(@site_name)[:browser].should eql('foo')
end

it "should provide default values if no config file or environment settings provided" do
Taza::Settings.stubs(:path).returns("spec/sandbox")
Taza::Settings.stubs(:path).returns("#{@original_directory}/spec/sandbox")
Taza::Settings.config(@site_name)[:driver].should eql('selenium')
Taza::Settings.config(@site_name)[:browser].should eql('firefox')
Taza::Settings.config(@site_name)[:attach].should eql(false)
end

it "should use environment variable for driver settings" do
Taza::Settings.stubs(:path).returns("spec/sandbox")
Taza::Settings.stubs(:path).returns("#{@original_directory}/spec/sandbox")
ENV['DRIVER'] = 'bar'
Taza::Settings.config(@site_name)[:driver].should eql('bar')
end

it "should be able to load the site yml" do
Taza::Settings.stubs(:path).returns("spec/sandbox")
Taza::Settings.stubs(:path).returns("#{@original_directory}/spec/sandbox")
Taza::Settings.config("SiteName")[:url].should eql('http://google.com')
end

it "should be able to load a alternate site url" do
ENV['TAZA_ENV'] = 'clown_shoes'
Taza::Settings.stubs(:path).returns("spec/sandbox")
Taza::Settings.stubs(:path).returns("#{@original_directory}/spec/sandbox")
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
UserChoices::YamlConfigFileSource.any_instance.stubs(:format_specific_reading).returns({'browser' => 'fu'})
Taza::Settings.stubs(:path).returns("./spec/sandbox")
Taza::Settings.stubs(:path).returns("#{@original_directory}//spec/sandbox")
Taza::Settings.config(@site_name)[:browser].should eql('fu')
end

it "should use the ENV variables if specfied instead of config files" do
ENV['BROWSER'] = 'opera'
UserChoices::YamlConfigFileSource.any_instance.stubs(:format_specific_reading).returns({'browser' => 'fu'})
Taza::Settings.stubs(:path).returns("spec/sandbox")
Taza::Settings.stubs(:path).returns("#{@original_directory}/spec/sandbox")
Taza::Settings.config(@site_name)[:browser].should eql('opera')
end

it "should use the correct config file to set defaults" do
Taza::Settings.stubs(:path).returns("spec/sandbox")
Taza::Settings.stubs(:path).returns("#{@original_directory}/spec/sandbox")
Taza::Settings.stubs(:config_file_path).returns('spec/sandbox/config.yml')
end

it "should raise error for a config file that doesnot exist" do
Taza::Settings.stubs(:path).returns('spec/sandbox/file_not_exists.yml')
Taza::Settings.stubs(:path).returns("#{@original_directory}/spec/sandbox/file_not_exists.yml")
lambda {Taza::Settings.config}.should raise_error
end

Expand All @@ -76,7 +76,7 @@

it "should use the config file's variable for driver settings if no environment variable is set" do
UserChoices::YamlConfigFileSource.any_instance.stubs(:format_specific_reading).returns({'driver' => 'fun'})
Taza::Settings.stubs(:path).returns("spec/sandbox")
Taza::Settings.stubs(:path).returns("#{@original_directory}/spec/sandbox")
Taza::Settings.config(@site_name)[:driver].should eql('fun')
end

Expand All @@ -85,7 +85,7 @@ class SiteName < Taza::Site
end

it "a site should be able to load its settings" do
Taza::Settings.stubs(:path).returns("spec/sandbox")
Taza::Settings.stubs(:path).returns("#{@original_directory}/spec/sandbox")
SiteName.settings[:url].should eql('http://google.com')
end

Expand Down

0 comments on commit a9e832e

Please sign in to comment.