spec/druid/page_factory_spec.rb in druid-ts-1.1.8 vs spec/druid/page_factory_spec.rb in druid-ts-1.2.0
- old
+ new
@@ -24,13 +24,19 @@
include Druid
page_url "http://google.co.uk"
end
end
-class TestWorld
- include Druid::PageFactory
+class WorldSuper
+ attr_reader :super_called
+ def on_page(cls, params={}, visit=false, &block)
+ @super_called = true
+ end
+end
+class TestWorld < WorldSuper
+ include Druid::PageFactory
attr_accessor :driver
attr_accessor :current_page
end
describe Druid::PageFactory do
@@ -39,10 +45,17 @@
let(:driver) do
world.driver = mock_driver
driver = world.driver
end
+ it "should call super when non druid class passed" do
+ class NoDruid
+ end
+ world.on(NoDruid)
+ expect(world.super_called).to be true
+ end
+
it "should create a new page object and execute a block" do
expect(driver).not_to receive(:goto)
world.on_page FactoryTestDruid do |page|
expect(page).to be_instance_of FactoryTestDruid
end
@@ -217,19 +230,6 @@
expect(FactoryTestDruid).to receive(:new).and_return(fake_page)
expect(fake_page).to receive(:respond_to?).with(:a_method).and_return(false)
expect{world.navigate_to(AnotherPage)}.to raise_error
end
- it "should know how to continue routing from a location" do
- Druid::PageFactory.routes = {:default => [[FactoryTestDruid, :a_method], [AnotherPage, :b_method], [YetAnotherPage, :c_method]]}
- world.current_page = FactoryTestDruid.new(driver)
- f_page = FactoryTestDruid.new(driver)
- allow(FactoryTestDruid).to receive(:new).with(driver,false).and_return(f_page)
- allow(f_page).to receive(:respond_to?).with(:a_method).and_return(true)
- allow(f_page).to receive(:a_method)
- a_page = AnotherPage.new(driver)
- allow(AnotherPage).to receive(:new).with(driver,false).and_return(a_page)
- allow(a_page).to receive(:respond_to?).with(:b_method).and_return(true)
- allow(a_page).to receive(:b_method)
- expect(world.continue_navigation_to(YetAnotherPage).class).to eql YetAnotherPage
- end
end