Class: Line::Message::RSpec::Matchers::HaveQuickReply

Inherits:
Object
  • Object
show all
Defined in:
lib/line/message/rspec/matchers/have_quick_reply.rb

Overview

The quick reply matcher for RSpec to search for quick reply action in the message array.

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ HaveQuickReply

Returns a new instance of HaveQuickReply.



10
11
12
# File 'lib/line/message/rspec/matchers/have_quick_reply.rb', line 10

def initialize(expected)
  @expected = Utils.stringify_keys!(expected, deep: true)
end

Instance Method Details

#descriptionObject



14
15
16
17
18
# File 'lib/line/message/rspec/matchers/have_quick_reply.rb', line 14

def description
  return "have quick reply action" if @expected.nil?

  "have quick reply action matching #{@expected}"
end

#failure_messageObject



26
27
28
# File 'lib/line/message/rspec/matchers/have_quick_reply.rb', line 26

def failure_message
  "expected to find a quick reply message matching #{@expected}"
end

#matches?(actual) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


20
21
22
23
# File 'lib/line/message/rspec/matchers/have_quick_reply.rb', line 20

def matches?(actual)
  @actual = Utils.stringify_keys!(actual, deep: true)
  @actual.any? { |message| match_message(message) }
end