spec/page_spec.rb in bret-watircraft-0.4.2 vs spec/page_spec.rb in bret-watircraft-0.4.3
- old
+ new
@@ -117,10 +117,11 @@
browser.stubs(:goto)
Taza::Settings.stubs(:config).returns(:url => 'http://www.llamas.com')
page = CheckOutPage.new
page.site = Class.new(Taza::Site).new(:browser => browser)
page.full_url.should == 'http://www.llamas.com/check_out'
+ page.url.should == page.full_url
end
it "should create elements for fields" do
@page_class.field(:foo) {'element'}
@page_class.new.foo_field.should == 'element'
@@ -287,12 +288,13 @@
{:letter => 'y', :number => 2}
]
@page_class.class_eval do
element(:results_table) {fake_table}
table(:results) do
- field(:name){@row.element(:letter)}
- field(:phone){@row.element(:number)}
+ field(:name){row.element(:letter)}
+ field(:phone){row.element(:number)}
+ field(:missing){raise 'not found'}
end
end
@table_page = @page_class.new
@fake_table = fake_table
end
@@ -303,23 +305,23 @@
@table_page.results.row(:phone => 2).name.should == 'y'
end
it "fields should have underlying elements" do
uses_table_page
- @table_page.results.row(:name => 'x').phone_element.should exist
+ @table_page.results.row(:name => 'x').phone_field.should exist
end
it "should have elements" do
@page_class.class_eval do
element(:results_table) do FakeTable.new [
{:letter => 'x', :number => 1},
{:letter => 'y', :number => 2}
]
end
table(:results) do
- field(:name){@row.element(:letter)}
- element(:phone){@row.element(:number)}
+ field(:name){row.element(:letter)}
+ element(:phone){row.element(:number)}
end
end
@table_page = @page_class.new
@table_page.results.row(:name => 'x').phone.should be_a(FakeElement)
end
@@ -333,10 +335,13 @@
it "rows should exist" do
uses_table_page
@table_page.results.row(:name => 'x').should exist
end
-
+ it "should not raise an exception if a field isn't found" do
+ uses_table_page
+ @table_page.results.row(:missing => 'nada').should be_nil
+ end
end
end