class Line::Message::RSpec::Matchers::HaveTextMessage
The text message matcher for RSpec to search for text messages in the message array.
Public Class Methods
Source
# File lib/line/message/rspec/matchers/have_text_message.rb, line 10 def initialize(expected) @text, @options = expected @options = Utils.stringify_keys!(@options || {}) end
Public Instance Methods
Source
# 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
Source
# File lib/line/message/rspec/matchers/have_text_message.rb, line 33 def failure_message 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
Source
# 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 |message| next unless message["type"] == "text" next true if @text.nil? message["text"].match?(@text) && ::RSpec::Matchers::BuiltIn::Include.new(@options).matches?(message) end end
Also aliased as: ==