Class: Line::Message::RSpec::Matchers::HaveTextMessage
- Inherits:
-
Object
- Object
- Line::Message::RSpec::Matchers::HaveTextMessage
- Defined in:
- lib/line/message/rspec/matchers/have_text_message.rb
Overview
The text message matcher for RSpec to search for text messages in the message array.
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(expected) ⇒ HaveTextMessage
constructor
A new instance of HaveTextMessage.
- #matches?(actual) ⇒ Boolean (also: #==)
Constructor Details
#initialize(expected) ⇒ HaveTextMessage
Returns a new instance of HaveTextMessage.
10 11 12 13 |
# File 'lib/line/message/rspec/matchers/have_text_message.rb', line 10 def initialize(expected) @text, @options = expected @options = Utils.stringify_keys!(@options || {}) end |
Instance Method Details
#description ⇒ Object
15 16 17 18 19 20 |
# File 'lib/line/message/rspec/matchers/have_text_message.rb', line 15 def description return "have text message" if @text.nil? return "have text message matching #{@text.inspect}" if @options.empty? "have text message matching #{@text.inspect} with options #{@options.inspect}" end |
#failure_message ⇒ Object
33 34 35 36 37 38 |
# File 'lib/line/message/rspec/matchers/have_text_message.rb', line 33 def return "expected to find a text message" if @text.nil? return "expected to find a text message matching #{@text.inspect}" if @options.empty? "expected to find a text message matching #{@text.inspect} with options #{@options.inspect}" end |
#matches?(actual) ⇒ Boolean Also known as: ==
22 23 24 25 26 27 28 29 30 |
# File 'lib/line/message/rspec/matchers/have_text_message.rb', line 22 def matches?(actual) @actual = Utils.stringify_keys!(actual, deep: true) @actual.any? do || next unless ["type"] == "text" next true if @text.nil? ["text"].match?(@text) && ::RSpec::Matchers::BuiltIn::Include.new(@options).matches?() end end |