Sha256: c78e570b86d6507cd00d43d715389639431ea855968a780dab90052014afc8e6

Contents?: true

Size: 611 Bytes

Versions: 1

Compression:

Stored size: 611 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)
    @actual == expected_hash
  end

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
message-driver-0.4.0 features/support/message_table_matcher.rb