it "calls #create if #find_or_create is called and no matching record exists" do
snack = class_spy(Snack, find_by_name: nil)
attrs = {name: 'test', location: 'test'}
snack.find_or_creat
我在控制器中有一个flash消息,我想用rspec来测试它。 在我的控制器中,如果数据库为空,则设置flash[:notice],否则为零。 def show
if(User.first.nil?)
flash[:notice] = "database is empty!"
end
end
然后在RSpec的文件我想测试两种情况: 我:当flash[:notic
RSpec文档显然是opposed to expect_any_instance_of,称它只应用于遗留代码,所以我正在寻找最佳实践替代方案。 我在使用expect_any_instance_of很多的情况下,我想测试一个方法将在满足某些条件时被调用,但是对象将被加载到不同的作用域中。 例如,写一个控制器规范的时候,我只是想测试正确的方法被调用正确的参数X上的一个实例
我有以下: let(:update_request) { put "/api/v3/account/profile.json", attributes, credentials }
describe "PUT 'update'" do
before { update_request }
context "updating normal attributes (no pas