Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I custom diffable's behaviour by just comparing obj's attributes? #627

Closed
tony612 opened this issue Aug 15, 2014 · 1 comment
Closed

Comments

@tony612
Copy link

tony612 commented Aug 15, 2014

I have a custom matcher for rails's AR like this:

RSpec::Matchers.define :has_same_attributes_as do |expected|
  ignored = %w[id updated_at created_at]
  match do |actual|
    actual.attributes.except(*ignored) == expected.attributes.except(*ignored)
  end

  failure_message do |actual|
    "Expected strength of #{expected.attributes.except(*ignored)}, but had #{actual.attributes.except(*ignored)}"
  end

  diffable
end

I just want to compare the attributes except id created_at updated_at, but when I use diffable it still returns the diff about excepted obj and actual obj instead of their attributes.

Is there any way to solve this? thx

@tony612 tony612 changed the title Can I custom diffable's behaviour by compare obj's attributes? Can I custom diffable's behaviour by just comparing obj's attributes? Aug 15, 2014
@myronmarston
Copy link
Member

Is there any way to solve this? thx

Not currently. There's been a long standing discussion about custom differs (#97) that would allow you to do things like this, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants