Class: Line::Message::RSpec::Matchers::HaveFlexBubble

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

Overview

The flex component matcher for RSpec to search nested flex components in the message array.

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ HaveFlexBubble

Returns a new instance of HaveFlexBubble.



10
11
12
# File 'lib/line/message/rspec/matchers/have_flex_bubble.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_flex_bubble.rb', line 14

def description
  return "have flex bubble" if @expected.empty?

  "have flex bubble matching #{@expected.inspect}"
end

#failure_messageObject



26
27
28
29
30
# File 'lib/line/message/rspec/matchers/have_flex_bubble.rb', line 26

def failure_message
  return "expected to find a flex bubble" if @expected.empty?

  "expected to find a flex bubble matching #{@expected.inspect}"
end

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

Returns:

  • (Boolean)


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

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