How do I write this with rspec
capybara, rspec, ruby-on-rails, ruby-on-rails-3, tdd
Solution
Here's the doc on using expectations
it "should delete a company" do
expect { click_link "Delete Company" }.to change{Company.count}.by(-1)
end
Note the following changes
- `should` becomes `to`
- `(Company, :count)` becomes `{Company.count}`
Problem
I upgraded my version of rspec to the most current version and I have tests breaking that have similar syntax ``` it "should delete a company" do expect { click_link "Delete Company" }.should change(Company, :count).by(-1) end ``` I looked at the documentation and I could not see anything that will do this in the current verion...any ideas on how to achieve this The error I get is ``` 9) Company Pages Edit page as an admin user should delete a company Failure/Error: expect { click_link "Delete Company" }.should change(Company, :count).by(-1) NoMethodError: undefined method `call' for #<RSpec::Expectations::ExpectationTarget:0x007fccafdfc360> # ./spec/requests/companies_spec.rb:79:in `block (3 levels) in <top (required)>' ```