Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Maintain Capybara 2 behavior for Capybara 3 #95

@codener

Description

@codener

Capybara 3 has changed the page.has_text? method that is used e.g. by the I should (not) see … steps to respect white space, including \n. This breaks tests that rely on the previous behavior, which normalized all white space like Rails' squish.

Fortunately, the has_text? method takes options and passes them to assert_text. This method takes a :normalize_ws option that restores the previous behavior if set to true:

https://github.com/teamcapybara/capybara/blob/5146c4aa1f7bd95a0520582aa34ecf55243ea313/lib/capybara/node/matchers.rb#L662

An update for the I should see … steps could look like this:

patiently do
  expect(page).to have_text(text, normalize_ws: true)
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions