spec/page_models/base_spec.rb in pagemodels-0.1.2 vs spec/page_models/base_spec.rb in pagemodels-0.1.3
- old
+ new
@@ -16,29 +16,28 @@
def verify!
true
end
end
+ before(:each) do
+ PageModels::Configuration.instance.stub(:driver).and_return(Watir::Browser.new(:chrome))
+ @page_model = TestPageModel.new
+ end
+
describe "template methods which must be implemented by your page models" do
it "should raise an error if page models do not implement #url" do
lambda { UnimplementedPageModel.new.url }.should raise_error(PageModels::ImplementationError)
- end
+ end
it "should raise an error if page models do not implement #verify!" do
lambda { UnimplementedPageModel.new.verify! }.should raise_error(PageModels::ImplementationError)
end
end
describe "delegating methods to the driver for less verbose page models" do
- before(:each) do
- @driver = Object.new
- PageModels::Configuration.instance.stub(:driver).and_return(@driver)
- @page_model = TestPageModel.new
- end
-
it "should delegate a missing method to the driver" do
- @driver.should_receive(:do_something_cool).with(:please)
+ PageModels::Configuration.instance.driver.should_receive(:do_something_cool).with(:please)
@page_model.do_something_cool(:please)
end
it "should should not hide method missing errors if the method does not exist on the driver" do
lambda { @page_model.do_something_else }.should raise_error(NoMethodError, "undefined method `do_something_else' for #{@page_model.inspect}")
@@ -47,11 +46,10 @@
describe "constructing page URLs" do
before(:each) do
PageModels::Configuration.instance.stub(:driver).and_return(Capybara::Session.new)
PageModels::Configuration.instance.base_url = "https://1.2.3.4:4321"
- @page_model = TestPageModel.new
end
it "uses the base URL from config" do
pm = TestPageModel.new("/foo")
pm.should_receive(:visit).with("https://1.2.3.4:4321/foo")
@@ -72,14 +70,10 @@
pm.should_receive(:verify!)
pm.open!
end
end
- describe "opening a page with driver" do
- before(:each) do
- @page_model = TestPageModel.new
- end
-
+ describe "opening a page with driver" do
describe "for capybara" do
it "should visit the page, then call verify" do
PageModels::Configuration.instance.stub(:driver).and_return(Capybara::Session.new)
@page_model.should_receive(:visit).with("http://test-page")
@page_model.should_receive(:verify!)
\ No newline at end of file