spec/site_spec.rb in taza-0.8.0 vs spec/site_spec.rb in taza-0.8.2

- old
+ new

@@ -3,60 +3,40 @@ require 'taza' describe Taza::Site do before :all do - @pages_path = File.join("spec","sandbox","pages","foo","*.rb") + @pages_path = File.join("spec","sandbox","pages","foo","**","*.rb") + @flows_path = File.join("spec","sandbox","flows","*.rb") Foo = Class.new(Taza::Site) end before :each do Foo.any_instance.stubs(:pages_path).returns(@pages_path) - ENV['browser'] = nil - ENV['driver'] = nil + ENV['BROWSER'] = nil + ENV['DRIVER'] = nil Taza::Settings.stubs(:config_file).returns({}) Taza::Settings.stubs(:site_file).returns({}) Taza::Site.before_browser_closes {} end it "pages_path should contain the site class name" do browser = stub_browser Taza::Browser.stubs(:create).returns(browser) Bax = Class.new(Taza::Site) - Bax.new.pages_path.should eql("./lib/sites/bax/pages/*.rb") + Bax.new.pages_path.should eql("./lib/sites/bax/pages/**/*.rb") end - it "should execute a flow with given parameters" do + it "should have flows defined as instance methods" do browser = stub_browser Taza::Browser.stubs(:create).returns(browser) - params = {} - require 'spec/sandbox/flows/batman' - Batman.any_instance.expects(:run).with(params) Barz = Class.new(Taza::Site) Barz.any_instance.stubs(:path).returns('spec/sandbox') - Barz.new.flow(:batman,params) + Barz.any_instance.stubs(:flows_path).returns(@flows_path) + Barz.new.batman_flow.should == "i am batman" end - it "should require a flow once it is called" do - browser = stub_browser - Taza::Browser.stubs(:create).returns(browser) - Class.constants.include?('Robin').should be_false - Bayz = Class.new(Taza::Site) - Bayz.any_instance.stubs(:path).returns('spec/sandbox') - Bayz.new.flow(:robin,{}) - Robin - end - - it "should create a browser using environment variables" do - browser = stub_browser - browser.stubs(:goto) - Taza::Browser.expects(:create_watir_ie).returns browser - ENV['browser'] = 'ie' - ENV['driver'] = 'watir' - f = Foo.new - end - it "should open watir browsers at the configuration URL" do browser = stub_browser browser.expects(:goto).with('a_url') Taza::Browser.stubs(:create).returns(browser) Taza::Settings.stubs(:config).returns(:url => 'a_url') @@ -146,10 +126,11 @@ klass.any_instance.stubs(:pages_path).returns(@pages_path) klass.new do |site| site.should respond_to(:bar) end end + it "should yield after browser has been setup" do Taza::Browser.stubs(:create).returns(stub_browser) klass = Class::new(Taza::Site) klass.any_instance.stubs(:pages_path).returns(@pages_path) klass.new do |site| @@ -162,10 +143,19 @@ Taza::Browser.stubs(:create).returns(browser) foo = Foo.new foo.bar.browser.should eql(browser) end + it "should add partials defined under the pages directory" do + Taza::Browser.stubs(:create).returns(stub_browser) + klass = Class::new(Taza::Site) + klass.any_instance.stubs(:pages_path).returns(@pages_path) + klass.new do |site| + site.partial_the_reckoning + end + end + it "should have a way to evaluate a block of code before site closes the browser" do browser = stub() browser.stubs(:goto) Taza::Browser.stubs(:create).returns(browser) browser_state = states('browser_open_state').starts_as('on') @@ -234,6 +224,6 @@ browser.stubs(:close) browser.stubs(:goto) browser end -end \ No newline at end of file +end