2012-07-21 16:44:10 -04:00
|
|
|
Capybara::SpecHelper.spec '#find_field' do
|
|
|
|
before do
|
|
|
|
@session.visit('/form')
|
|
|
|
end
|
2009-12-15 14:58:51 -05:00
|
|
|
|
2012-07-21 16:44:10 -04:00
|
|
|
it "should find any field" do
|
|
|
|
@session.find_field('Dog').value.should == 'dog'
|
|
|
|
@session.find_field('form_description').text.should == 'Descriptive text goes here'
|
|
|
|
@session.find_field('Region')[:name].should == 'form[region]'
|
|
|
|
end
|
2009-12-15 14:58:51 -05:00
|
|
|
|
2012-09-06 03:33:43 -04:00
|
|
|
it "casts to string" do
|
|
|
|
@session.find_field(:'Dog').value.should == 'dog'
|
|
|
|
end
|
|
|
|
|
2012-07-21 16:44:10 -04:00
|
|
|
it "should raise error if the field doesn't exist" do
|
2012-10-30 09:26:19 -04:00
|
|
|
expect do
|
2012-07-21 16:44:10 -04:00
|
|
|
@session.find_field('Does not exist')
|
2012-10-30 09:26:19 -04:00
|
|
|
end.to raise_error(Capybara::ElementNotFound)
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
2009-12-15 14:58:51 -05:00
|
|
|
|
2012-07-21 16:44:10 -04:00
|
|
|
it "should be aliased as 'field_labeled' for webrat compatibility" do
|
|
|
|
@session.field_labeled('Dog').value.should == 'dog'
|
2012-10-30 09:26:19 -04:00
|
|
|
expect do
|
2012-07-21 16:44:10 -04:00
|
|
|
@session.field_labeled('Does not exist')
|
2012-10-30 09:26:19 -04:00
|
|
|
end.to raise_error(Capybara::ElementNotFound)
|
2009-12-15 14:58:51 -05:00
|
|
|
end
|
2010-01-18 14:33:22 -05:00
|
|
|
end
|