You can add your own support for the absent not_change
matcher.
You can test that mutliple attributes of an object have changed like this:
expect do
req
sku.reload
end.to change(sku, :code)
.and change(sku, :price)
But you can’t do the opposite:
expect do
req
sku.reload
end.to not_change(sku, :code)
.and not_change(sku, :price)
What you can do is define not_change
to support this:
RSpec::Matchers.define_negated_matcher :not_change, :change
— John Norris
Who are Dragon Drop?
Dragon Drop is a specialist web and app development agency. The team has extensive full-stack technical credentials and a strong focus on user experience.
The Dragon Drop founding team have over 40 years of web development and project experience. They have managed or developed over 100 significant ecommerce and web projects during their careers, including implementations for major UK high street retailers, financial services companies and government agencies.
Their approach to innovative solutions stems from perspectives gained as retailer, software supplier and web agency.