Sha256: 33eb63e81f34e914b3c4be5eb831f18d5d57a7febd36e4eb012cd08bb9ddaa7d

Contents?: true

Size: 630 Bytes

Versions: 11

Compression:

Stored size: 630 Bytes

Contents

RSpec::Matchers.define :match_message_table do |expected_tbl|
  define_method :expected_hash do
    @expected_hash ||= expected_tbl.hashes
  end

  define_method :messages_to_hash do |messages|
    messages.map do |msg|
      expected_tbl.headers.each_with_object({}) do |method, hash|
        hash[method] = msg.send(method)
      end
    end
  end

  match do |messages|
    @actual = messages_to_hash(messages)
    expect(@actual).to match_array(expected_hash)
    true
  end

  failure_message do |_|
    "expected #{expected_hash} and got #{@actual}"
  end

  description do
    "contain messages #{expected_hash}"
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
message-driver-1.0.1 features/support/message_table_matcher.rb
message-driver-1.0.0 features/support/message_table_matcher.rb
message-driver-0.7.2 features/support/message_table_matcher.rb
message-driver-0.7.1 features/support/message_table_matcher.rb
message-driver-0.7.0 features/support/message_table_matcher.rb
message-driver-0.6.1 features/support/message_table_matcher.rb
message-driver-0.6.0 features/support/message_table_matcher.rb
message-driver-0.5.3 features/support/message_table_matcher.rb
message-driver-0.5.2 features/support/message_table_matcher.rb
message-driver-0.5.1 features/support/message_table_matcher.rb
message-driver-0.5.0 features/support/message_table_matcher.rb