Class: Appydays::SpecHelpers::HaveALineMatching
- Inherits:
-
Object
- Object
- Appydays::SpecHelpers::HaveALineMatching
- Includes:
- RSpec::Matchers::Composable
- Defined in:
- lib/appydays/spec_helpers.rb
Overview
:section: Matchers
Instance Method Summary collapse
- #failure_message ⇒ Object (also: #failure_message_for_should)
- #failure_message_when_negated ⇒ Object (also: #failure_message_for_should_not)
-
#initialize(regexp) ⇒ HaveALineMatching
constructor
A new instance of HaveALineMatching.
- #matches?(target) ⇒ Boolean
Constructor Details
#initialize(regexp) ⇒ HaveALineMatching
Returns a new instance of HaveALineMatching.
24 25 26 |
# File 'lib/appydays/spec_helpers.rb', line 24 def initialize(regexp) @regexp = regexp end |
Instance Method Details
#failure_message ⇒ Object Also known as: failure_message_for_should
36 37 38 |
# File 'lib/appydays/spec_helpers.rb', line 36 def return "expected %p to have at least one line matching %p" % [@target, @regexp] end |
#failure_message_when_negated ⇒ Object Also known as: failure_message_for_should_not
42 43 44 |
# File 'lib/appydays/spec_helpers.rb', line 42 def return "expected %p not to have any lines matching %p, but it has at least one" % [@target, @regexp] end |
#matches?(target) ⇒ Boolean
28 29 30 31 32 33 34 |
# File 'lib/appydays/spec_helpers.rb', line 28 def matches?(target) @target = target @target = @target.lines if @target.is_a?(String) return @target.find do |obj| obj.to_s.match(@regexp) end end |