lib/capybara/spec/session/find_field_spec.rb in capybara-2.18.0 vs lib/capybara/spec/session/find_field_spec.rb in capybara-3.0.0.rc1

- old
+ new

@@ -1,6 +1,7 @@ # frozen_string_literal: true + Capybara::SpecHelper.spec '#find_field' do before do @session.visit('/form') end @@ -24,40 +25,33 @@ # expect { @session.find_field('Emergency Number') }.to raise_error(Capybara::ElementNotFound) end end it "casts to string" do - expect(@session.find_field(:'Dog').value).to eq('dog') + expect(@session.find_field(:Dog).value).to eq('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 warn if filter option is invalid" do - expect_any_instance_of(Kernel).to receive(:warn). - with('Invalid value nil passed to filter disabled - defaulting to false') - @session.find_field('Dog', disabled: nil) - end - - it "should be aliased as 'field_labeled' for webrat compatibility" do - expect(@session.field_labeled('Dog').value).to eq('dog') + it "should raise error if filter option is invalid" do expect do - @session.field_labeled('Does not exist') - end.to raise_error(Capybara::ElementNotFound) + @session.find_field('Dog', disabled: nil) + end.to raise_error ArgumentError, "Invalid value nil passed to filter disabled" 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 @@ -110,8 +104,8 @@ 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" + expect(@session.find_field('form[pets][]') { |node| node.value == 'dog' }[:id]).to eq "form_pets_dog" end end