lib/capybara/spec/session/find_field_spec.rb in capybara-2.9.2 vs lib/capybara/spec/session/find_field_spec.rb in capybara-2.10.0

- old
+ new

@@ -6,11 +6,10 @@ it "should find any field" do expect(@session.find_field('Dog').value).to eq('dog') expect(@session.find_field('form_description').text).to eq('Descriptive text goes here') expect(@session.find_field('Region')[:name]).to eq('form[region]') - end context "aria_label attribute with Capybara.enable_aria_label" do it "should find when true" do Capybara.enable_aria_label = true @@ -48,43 +47,43 @@ end.to raise_error(Capybara::ElementNotFound) end context "with :exact option" do it "should accept partial matches when false" do - expect(@session.find_field("Explanation", :exact => false)[:name]).to eq("form[name_explanation]") + expect(@session.find_field("Explanation", exact: false)[:name]).to eq("form[name_explanation]") end it "should not accept partial matches when true" do expect do - @session.find_field("Explanation", :exact => true) + @session.find_field("Explanation", exact: true) end.to raise_error(Capybara::ElementNotFound) end end context "with :disabled option" do it "should find disabled fields when true" do - expect(@session.find_field("Disabled Checkbox", :disabled => true)[:name]).to eq("form[disabled_checkbox]") + expect(@session.find_field("Disabled Checkbox", disabled: true)[:name]).to eq("form[disabled_checkbox]") end it "should not find disabled fields when false" do expect do - @session.find_field("Disabled Checkbox", :disabled => false) + @session.find_field("Disabled Checkbox", disabled: false) end.to raise_error(Capybara::ElementNotFound) end it "should not find disabled fields by default" do expect do @session.find_field("Disabled Checkbox") end.to raise_error(Capybara::ElementNotFound) end it "should find disabled fields when :all" do - expect(@session.find_field("Disabled Checkbox", :disabled => :all)[:name]).to eq("form[disabled_checkbox]") + expect(@session.find_field("Disabled Checkbox", disabled: :all)[:name]).to eq("form[disabled_checkbox]") end it "should find enabled fields when :all" do - expect(@session.find_field('Dog', :disabled => :all).value).to eq('dog') + expect(@session.find_field('Dog', disabled: :all).value).to eq('dog') end end context 'with :readonly option' do it "should find readonly fields when true" do @@ -104,7 +103,12 @@ context 'with no locator' do it 'should use options to find the field' do expect(@session.find_field(with: 'dog')['id']).to eq "form_pets_dog" end + end + + it "should accept an optional filter block" do + # this would be better done with the :with option but this is just a test + expect(@session.find_field('form[pets][]'){ |node| node.value == 'dog' }[:id]).to eq "form_pets_dog" end end