Use page.find instead of within in component tests
In component tests, the `within` method is actually an alias to RSpec's `be_within` matcher, which is used to test numeric ranges. That meant the tests always passed, even when there were bugs on the page. In order to use `within` in component tests, we have to use `page.within`. However, that also fails, since there's no such method for `Capybara::Node::Simple'` objects, which are used in component tests. So we're using `page.find` instead. See also pull request 945 in https://github.com/github/view_component
This commit is contained in:
@@ -33,9 +33,9 @@ describe Admin::BudgetsWizard::Headings::GroupSwitcherComponent do
|
||||
expect(page).to have_content "Showing headings from the Parks group"
|
||||
expect(page).to have_button "Manage headings from a different group"
|
||||
|
||||
within "button + ul" do
|
||||
expect(page).to have_link "Recreation"
|
||||
expect(page).to have_link "Entertainment"
|
||||
page.find("button + ul") do |list|
|
||||
expect(list).to have_link "Recreation"
|
||||
expect(list).to have_link "Entertainment"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user