1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

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