Class: Logux::Test::Matchers::SendToLogux

Inherits:
Base
  • Object
show all
Defined in:
lib/logux/test/matchers/send_to_logux.rb

Instance Attribute Summary

Attributes inherited from Base

#expected

Instance Method Summary collapse

Methods inherited from Base

#initialize, #supports_block_expectations?

Constructor Details

This class inherits a constructor from Logux::Test::Matchers::Base

Instance Method Details

#failure_messageObject



22
23
24
25
# File 'lib/logux/test/matchers/send_to_logux.rb', line 22

def failure_message
  "expected that #{pretty(@difference)} to include "\
    "commands #{pretty(expected)}"
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/logux/test/matchers/send_to_logux.rb', line 9

def matches?(actual)
  @difference = state_changes_inside { actual.call }
  return !@difference.empty? if expected.empty?

  expected.all? do |ex|
    @difference.find do |state|
      state['commands'].any? do |c|
        match_commands?(c, ex)
      end
    end
  end
end