Sha256: ef5afca65653121e8cdf1eec33720fde81967788d40dd9caf8c3a8602e8fd946

Contents?: true

Size: 519 Bytes

Versions: 11

Compression:

Stored size: 519 Bytes

Contents

# Compares the attributes of two models or hashes, ignoring attributes generated only when saving in the db
# Example: user1.should have_same_attributes_as(User.last)
RSpec::Matchers.define :have_same_attributes_as do |expected|
  match do |actual|
    ignored = ['id', 'updated_at', 'created_at']
    actual_attr = actual.attributes unless actual.instance_of?(Hash)
    expected_attr = expected.attributes unless expected.instance_of?(Hash)
    actual_attr.except(*ignored) == expected_attr.except(*ignored)
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
bigbluebutton_rails-1.2.0 spec/support/matchers/have_same_attributes_as.rb
bigbluebutton_rails-1.1.0 spec/support/matchers/have_same_attributes_as.rb
bigbluebutton_rails-1.0.0 spec/support/matchers/have_same_attributes_as.rb
bigbluebutton_rails-0.1.1 spec/support/matchers/have_same_attributes_as.rb
bigbluebutton_rails-0.1.0 spec/support/matchers/have_same_attributes_as.rb
bigbluebutton_rails-0.0.6 spec/support/matchers/have_same_attributes_as.rb
bigbluebutton_rails-0.0.5 spec/support/matchers/have_same_attributes_as.rb
bigbluebutton_rails-0.0.4 spec/support/matchers/have_same_attributes_as.rb
bigbluebutton_rails-0.0.3 spec/support/matchers/have_same_attributes_as.rb
bigbluebutton_rails-0.0.2 spec/support/matchers/have_same_attributes_as.rb
bigbluebutton_rails-0.0.1 spec/support/matchers/have_same_attributes_as.rb