Define assertions and spec expectations for both positive and negative forms of the matcher name.
# File lib/capybara_minitest_spec.rb, line 13 def add_matcher(matcher_name) positive_name = CapybaraMiniTestSpec::PositiveTestName.new(matcher_name) negative_name = CapybaraMiniTestSpec::NegativeTestName.new(matcher_name) [positive_name, negative_name].each do |test_name| CapybaraMiniTestSpec.define_expectation(test_name) end end
Define an assertion using test_name. For example, if the test name is have_css, the assertion would be called assert_page_has_css.
Use either of Capybara::RSpecMatchers. Assert that it matches, and pass its failure message if it doesn't.
# File lib/capybara_minitest_spec.rb, line 32 def define_assertion(test_name) method_name = test_name.assertion_name MiniTest::Assertions.send :define_method, method_name do |page, *args| matcher = test_name.matcher(*args) matches = matcher.send(test_name.match_method, page) failure_message = message do matcher.send(test_name.failure_message_method) end assert matches, failure_message end end
Generated with the Darkfish Rdoc Generator 2.