Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

not_to change.by() is not supported

I upgraded rspec version from 2 to 3. This is one of the issues I faced:

Failures:    1) Slide after .destroy(force: false) visible if .with_deleted      Failure/Error: expect{@slide.destroy(force: false)}.to_not change(Slide.with_deleted, :count).by(1)      NotImplementedError:        `expect { }.not_to change { }.by()` is not supported      # ./spec/models/slide_spec.rb:36:in `block (3 levels) in <top (required)>' 

and in the rspec's changelog I can read it was never supported (oink ?!@#). At the same time there are still some examples how to use change syntax but without not keyword.

So the question is how to expect no change ?

like image 251
pawel7318 Avatar asked Aug 12 '14 15:08

pawel7318


1 Answers

Fortunately I want to expect no change (any) so I can omit by() part. It works just fine !

  expect{@slide.destroy(force: false)}.to_not change(Slide.with_deleted, :count) 
like image 64
pawel7318 Avatar answered Sep 17 '22 15:09

pawel7318