Class: SwissKnife::RSpec::Matchers::HaveText
- Inherits:
-
Object
- Object
- SwissKnife::RSpec::Matchers::HaveText
- Defined in:
- lib/swiss_knife/rspec/have_text.rb
Instance Attribute Summary collapse
-
#matcher ⇒ Object
Returns the value of attribute matcher.
-
#regex ⇒ Object
Returns the value of attribute regex.
-
#subject ⇒ Object
Returns the value of attribute subject.
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(matcher) ⇒ HaveText
constructor
A new instance of HaveText.
- #matches?(text) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(matcher) ⇒ HaveText
Returns a new instance of HaveText.
11 12 13 |
# File 'lib/swiss_knife/rspec/have_text.rb', line 11 def initialize(matcher) @matcher = matcher end |
Instance Attribute Details
#matcher ⇒ Object
Returns the value of attribute matcher.
9 10 11 |
# File 'lib/swiss_knife/rspec/have_text.rb', line 9 def matcher @matcher end |
#regex ⇒ Object
Returns the value of attribute regex.
9 10 11 |
# File 'lib/swiss_knife/rspec/have_text.rb', line 9 def regex @regex end |
#subject ⇒ Object
Returns the value of attribute subject.
9 10 11 |
# File 'lib/swiss_knife/rspec/have_text.rb', line 9 def subject @subject end |
Instance Method Details
#description ⇒ Object
26 27 28 |
# File 'lib/swiss_knife/rspec/have_text.rb', line 26 def description "have text #{matcher.inspect}" end |
#failure_message ⇒ Object
30 31 32 |
# File 'lib/swiss_knife/rspec/have_text.rb', line 30 def "expected #{subject.inspect} to include #{matcher.inspect}" end |
#matches?(text) ⇒ Boolean
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/swiss_knife/rspec/have_text.rb', line 15 def matches?(text) @subject = text.to_s case matcher when String subject.index(matcher) when Regexp subject.match(matcher) end end |
#negative_failure_message ⇒ Object
34 35 36 |
# File 'lib/swiss_knife/rspec/have_text.rb', line 34 def "expected #{subject.inspect} to exclude #{matcher.inspect}" end |