Sha256: bcedb5a8cb7b38b776b305db91e90f4bb0f2e855c2205298a552303fc3766518

Contents?: true

Size: 610 Bytes

Versions: 6

Compression:

Stored size: 610 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.collect do |msg|
      expected_tbl.headers.inject({ }) do |memo, obj|
        memo[obj] = msg.send(obj)
        memo
      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

6 entries across 6 versions & 1 rubygems

Version Path
message-driver-0.3.0 features/support/message_table_matcher.rb
message-driver-0.2.2 features/support/message_table_matcher.rb
message-driver-0.2.1 features/support/message_table_matcher.rb
message-driver-0.2.0 features/support/message_table_matcher.rb
message-driver-0.2.0.rc2 features/support/message_table_matcher.rb
message-driver-0.2.0.rc1 features/support/message_table_matcher.rb