Class: CapybaraMiniTestSpec::Matcher::Name
- Inherits:
-
Object
- Object
- CapybaraMiniTestSpec::Matcher::Name
- Defined in:
- lib/capybara_minitest_spec/matcher.rb
Overview
Represents the a matcher name. Returns different forms of the name depending on whether it is in a positive or negative state.
Instance Attribute Summary collapse
-
#original ⇒ Object
readonly
Returns the value of attribute original.
Instance Method Summary collapse
- #assertion ⇒ Object
- #expectation ⇒ Object
- #have ⇒ Object
-
#initialize(name, positive) ⇒ Name
constructor
A new instance of Name.
- #negate! ⇒ Object
- #positive? ⇒ Boolean
- #without_question_mark ⇒ Object
Constructor Details
#initialize(name, positive) ⇒ Name
Returns a new instance of Name.
86 87 88 89 |
# File 'lib/capybara_minitest_spec/matcher.rb', line 86 def initialize(name, positive) @original = name.to_s @positive = positive end |
Instance Attribute Details
#original ⇒ Object (readonly)
Returns the value of attribute original.
84 85 86 |
# File 'lib/capybara_minitest_spec/matcher.rb', line 84 def original @original end |
Instance Method Details
#assertion ⇒ Object
107 108 109 110 111 112 113 |
# File 'lib/capybara_minitest_spec/matcher.rb', line 107 def assertion if positive? "assert_page_#{without_question_mark}" else "refute_page_#{without_question_mark}" end end |
#expectation ⇒ Object
115 116 117 118 119 120 121 |
# File 'lib/capybara_minitest_spec/matcher.rb', line 115 def expectation if positive? "must_#{have}" else "wont_#{have}" end end |
#have ⇒ Object
103 104 105 |
# File 'lib/capybara_minitest_spec/matcher.rb', line 103 def have without_question_mark.sub /has_/, 'have_' end |
#negate! ⇒ Object
95 96 97 |
# File 'lib/capybara_minitest_spec/matcher.rb', line 95 def negate! @positive = !positive? end |
#positive? ⇒ Boolean
91 92 93 |
# File 'lib/capybara_minitest_spec/matcher.rb', line 91 def positive? !!@positive end |
#without_question_mark ⇒ Object
99 100 101 |
# File 'lib/capybara_minitest_spec/matcher.rb', line 99 def without_question_mark @original.to_s.sub /\?$/, '' end |