Capybara has_field waiting for nil rspec when upgrading to 2.2

After I upgraded Capybara from 2.1.0 to 2.2.1 and Poltergeist from 1.4.1 to 1.5.0, the following rspec wait started in my rails application tests:

it{ expect(page).to have_field("foo_field_id", with: nil) }

The rspec error looks like this:

 Failure/Error: it{ expect(page).to have_field("foo_field_id", with: nil) }
 Capybara::ExpectationNotMet:
   expected to find field "foo_field_id" but there were no matches. Also found "", which matched the selector but not all filters.

If I throw a breakpoint for verification, the value is really zero:

»  page.find_field('foo_field_id').value
=> nil

If I change "from" to "text", the statement passes:

it{ expect(page).to have_field("foo_field_id", text: nil) }

The HTML form field is as follows:

<input class="string optional" id="foo_field_id" name="foo[field_id]" type="text">

Why is this happening?

+4
source share
1 answer

According to https://github.com/jnicklas/capybara/pull/1169 , this is due to a recent change:

nil , to_s , .

, - :

expect(find_field("foo_field_id").text).to be_blank
+3

Source: https://habr.com/ru/post/1542197/


All Articles