Frequently one might want to make an assertion inside a within block, but it's not obvious how to do so.
This doesn't work (within doesn't have block attributes):
within(level_selector) do |this|
click_button 'edit'
expect(this).to have_content(header_text) # sadly this = nil
end
current_scope
will work though and looks at only the content in the within
within(level_selector) do
click_button 'edit'
expect(current_scope).to have_content(header_text)
end
Actually,
expect(page)
will work as well. This is handy when you call a step from within another step.