I'm just getting started with feature specs using RSpec (and Capybara). I'm testing my ActiveAdmin dashboard and I want to check that all panels have an orders table as shown in this snippet:
feature 'admin dashboard', type: :feature do
def panels
page.all('.column .panel')
end
describe 'all panels' do
it 'have an orders table' do
expect(panels).to all(have_css('table.orders tbody'))
end
end
end
I've used the all
matcher a lot in my unit tests but it doesn't appear to work when wrapping Capybara's have_css
matcher because I'm getting the following error:
Failure/Error: expect(panels).to all(have_css('table.orders tbody'))
TypeError:
no implicit conversion of Capybara::RackTest::CSSHandlers into String
Am I correct in my assumption that RSpec's built-in all
matcher should work with other matchers as well?
Note: I'm using describe
and it
instead of feature
and scenario
in this instance because I'm testing output rather than user interaction scenarios (see my other question).
all
and Capybara'sall
see Capybara Issue 1396. Theall
that you are calling is actually Capybara'sall
. – Justin Ko