我将我的rspec版本升级到最新版本,我的测试打破了类似语法
it "should delete a company" do
expect { click_link "Delete Company" }.should change(Company, :count).by(-1)
end
我看了documentation,在目前的情况下我看不到任何可以做到这一点的事情......关于如何实现这一点的任何想法
我得到的错误是
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)>'
答案 0 :(得分:9)
以下是关于使用期望的doc
it "should delete a company" do
expect { click_link "Delete Company" }.to change{Company.count}.by(-1)
end
请注意以下更改
should
变为to
(Company, :count)
变为{Company.count}