I'm having trouble with equality matchers in RSpec and Draper decorated objects.
Specs to show what's going on:
context 'how to use the right equality matcher' do
let(:page) { build(:page) }
let(:decorated_page) { page.decorate }
it "should pass, but doesn't" do
expect(decorated_page).to_not eq page
end
it 'proves the classes are different' do
expect(decorated_page).to be_a PageDecorator
expect(page).to be_a Page
expect(decorated_page.class).to_not eq page.class
end
it 'has a work around' do
expect(decorated_page).to be_decorated_with PageDecorator
expect(page).to_not be_decorated_with PageDecorator
end
end
I know RSpec has a few different equality checkers, and that eq
is the "weakest" but I would have thought not having the same class would be a deal breaker.
As you can see, I have a work around for this case thanks to Draper's matchers. But I feel like I must be missing something for that test to fail.
Question:
What equality matcher should I use to get the should pass, but doesn't
test to pass?