Class: Line::Message::RSpec::Matchers::HaveFlexComponent
- Inherits:
-
Object
- Object
- Line::Message::RSpec::Matchers::HaveFlexComponent
- Defined in:
- lib/line/message/rspec/matchers/have_flex_component.rb
Overview
The flex component matcher for RSpec to search nested flex components in the message array.
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(expected_desc: nil, &expected) ⇒ HaveFlexComponent
constructor
A new instance of HaveFlexComponent.
- #matches?(actual) ⇒ Boolean (also: #==)
Constructor Details
#initialize(expected_desc: nil, &expected) ⇒ HaveFlexComponent
Returns a new instance of HaveFlexComponent.
10 11 12 13 |
# File 'lib/line/message/rspec/matchers/have_flex_component.rb', line 10 def initialize(expected_desc: nil, &expected) @expected = expected @expected_desc = expected_desc end |
Instance Method Details
#description ⇒ Object
15 16 17 18 19 20 |
# File 'lib/line/message/rspec/matchers/have_flex_component.rb', line 15 def description return "have flex component" if @expected.nil? return "have flex component matching #{@expected_desc}" if @expected_desc "have flex component matching #{@expected.inspect}" end |
#failure_message ⇒ Object
28 29 30 31 32 33 |
# File 'lib/line/message/rspec/matchers/have_flex_component.rb', line 28 def return "expected to find a flex component" if @expected.nil? return "expected to find a flex component matching #{@expected_desc}" if @expected_desc "expected to find a flex component matching #{@expected.inspect}" end |
#matches?(actual) ⇒ Boolean Also known as: ==
22 23 24 25 |
# File 'lib/line/message/rspec/matchers/have_flex_component.rb', line 22 def matches?(actual) @actual = Utils.stringify_keys!(actual, deep: true) @actual.any? { || match_flex_component?() } end |