Delegate block for "all" matcher of RSpec

This commit is contained in:
Akihiko Odaki 2018-02-14 13:56:49 +09:00
parent e2484e07c5
commit 7eba05f476
2 changed files with 4 additions and 3 deletions

View File

@ -2,11 +2,11 @@
module Capybara
module RSpecMatcherProxies
def all(*args)
def all(*args, &block)
if defined?(::RSpec::Matchers::BuiltIn::All) && args.first.respond_to?(:matches?)
::RSpec::Matchers::BuiltIn::All.new(*args)
else
find_all(*args)
find_all(*args, &block)
end
end

View File

@ -44,7 +44,8 @@ RSpec.describe 'capybara/rspec', :type => :feature do
context "#all" do
it "allows access to the Capybara finder" do
visit('/with_html')
expect(all(:css, 'h2.head').size).to eq(5)
found = all(:css, 'h2') { |element| element[:class] == 'head' }
expect(found.size).to eq(5)
end
it "allows access to the RSpec matcher" do