mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
40 lines
1.2 KiB
Ruby
40 lines
1.2 KiB
Ruby
Capybara::SpecHelper.spec '#find_field' do
|
|
before do
|
|
@session.visit('/form')
|
|
end
|
|
|
|
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
|
|
|
|
it "casts to string" do
|
|
@session.find_field(:'Dog').value.should == 'dog'
|
|
end
|
|
|
|
it "should raise error if the field doesn't exist" do
|
|
expect do
|
|
@session.find_field('Does not exist')
|
|
end.to raise_error(Capybara::ElementNotFound)
|
|
end
|
|
|
|
it "should be aliased as 'field_labeled' for webrat compatibility" do
|
|
@session.field_labeled('Dog').value.should == 'dog'
|
|
expect do
|
|
@session.field_labeled('Does not exist')
|
|
end.to raise_error(Capybara::ElementNotFound)
|
|
end
|
|
|
|
context "with :exact option" do
|
|
it "should accept partial matches when false" do
|
|
@session.find_field("Explanation", :exact => false)[:name].should == "form[name_explanation]"
|
|
end
|
|
|
|
it "should not accept partial matches when true" do
|
|
expect do
|
|
@session.find_field("Explanation", :exact => true)
|
|
end.to raise_error(Capybara::ElementNotFound)
|
|
end
|
|
end
|
|
end
|