我有以下 rspec 代码:
require 'spec_helper'
require 'mocha'
require 'rr'
describe ProjectsController, "creating a new project" do
integrate_views
it "should redirect to project with a notice on successful save" do
Project.any_instance.stubs(:valid?).returns(true)
#mock.instance_of(Project).valid? {true}
Project.any_instance.stubs(:create_default_packets)
#mock.instance_of(Project).create_default_packets
post 'create'
assigns[:project].should_not be_new_record
end
end
它以书面形式成功通过(RR 语法被注释掉)但是当我切换到 RR 语法时它失败了:
'ProjectsController 创建一个新项目应重定向到项目并通知成功保存' FAILED 预期 new_record?返回假,得到真
RR会失败的两者有什么区别?