Created
November 25, 2012 03:56
-
-
Save mkdynamic/4142336 to your computer and use it in GitHub Desktop.
Capybara assertion helpers for plain Test::Unit folks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'capybara/session' | |
# Provider `assert_page_has_X` helpers for all `has_X?` Capybara matchers | |
# | |
# For a full list, scope: | |
# https://github.com/jnicklas/capybara/blob/master/lib/capybara/session.rb | |
# | |
module CapybaraAssertions | |
Capybara::Session::DSL_METHODS.select { |m| m.to_s.match(/^has/) }.each do |m| | |
define_method "assert_page_#{m.to_s.sub(/\?$/, '')}" do |*args| | |
human_name = m.to_s.sub(/\?$/, '').sub('has_', 'have_').humanize.downcase | |
assert page.send(m, *args), "Expected page to #{human_name} with #{args.inspect}." | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment