Class: CapybaraMiniTestSpec::Matcher
- Inherits:
-
Object
- Object
- CapybaraMiniTestSpec::Matcher
- Defined in:
- lib/capybara_minitest_spec/matcher.rb
Defined Under Namespace
Classes: Name
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
-
.failure_message(assertion_method, matcher_name, *args) ⇒ Object
Compose failure message.
Instance Method Summary collapse
- #define_expectations ⇒ Object
-
#initialize(node_matcher_name) ⇒ Matcher
constructor
A new instance of Matcher.
-
#test(page, *args) ⇒ Object
Send page the matcher name with args.
- #undefine_assertions ⇒ Object
Constructor Details
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/capybara_minitest_spec/matcher.rb', line 4 def name @name end |
Class Method Details
.failure_message(assertion_method, matcher_name, *args) ⇒ Object
Compose failure message. E.g. Matcher failed: has_css?(“expected”, => 1)
33 34 35 36 37 38 39 40 |
# File 'lib/capybara_minitest_spec/matcher.rb', line 33 def self.(assertion_method, matcher_name, *args) if assertion_method == 'assert' = "Matcher failed: " else = 'Matcher should have failed: ' end += "#{matcher_name}(#{args.map(&:inspect).join(', ')})" end |
Instance Method Details
#define_expectations ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/capybara_minitest_spec/matcher.rb', line 11 def define_expectations # Define positive expectations. define_expectation # Define negative expectations. @name.negate! define_expectation end |
#test(page, *args) ⇒ Object
Send page the matcher name with args. E.g. page.has_css?(*args)
27 28 29 |
# File 'lib/capybara_minitest_spec/matcher.rb', line 27 def test(page, *args) wrap(page).send(name.original, *args) end |
#undefine_assertions ⇒ Object
19 20 21 22 23 |
# File 'lib/capybara_minitest_spec/matcher.rb', line 19 def undefine_assertions undefine_assertion @name.negate! undefine_assertion end |