Skip to content

Instantly share code, notes, and snippets.

@terut
Last active December 16, 2015 07:49
Show Gist options
  • Save terut/5401613 to your computer and use it in GitHub Desktop.
Save terut/5401613 to your computer and use it in GitHub Desktop.
Extend capybara for printing inner html.
# Put spec/support/capybara-finders_tap.rb
# Target: capybara 2.0.3
module Capybara
module Node
module Finders
# Usage:
# find('div.foo1'){|x| puts x.to_s }
#
def find_with_tap(*args)
if block_given?
synchronize { all(*args).tap{ |rs| rs.each {|r| yield(r.native)} }.find! }.tap(&:allow_reload!)
else
find_without_tap(*args)
end
end
alias_method_chain :find, :tap
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment