Sha256: f49be07bf844fb6b7b145fb7e1e89b59ad2f4c6c907811251f6c94e8897bf6d9
Contents?: true
Size: 709 Bytes
Versions: 6
Compression:
Stored size: 709 Bytes
Contents
require 'rspec/expectations' RSpec::Matchers.define :have_attributes do |expected| match do |actual| result = true expected.each do |key, value| result = false unless actual.send(key) == value end result end failure_message_for_should do |actual| wrong_fields = {} expected.each do |key, value| wrong_fields[key] = { actual: actual.send(key), expected: value } unless actual.send(key) == value end wrong_fields.inject("In #{actual.class.name} ") do |message, wrong_field| key, value = wrong_field message << "expected that #{key} would be #{value[:expected]}, but was #{value[:actual]}\n" message end end end
Version data entries
6 entries across 6 versions & 1 rubygems