0

我有以下 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会失败的两者有什么区别?

4

1 回答 1

0

看起来不同之处在于您不能使用 rr 调用 instance_of 两次。请参阅以下 git 问题:http: //github.com/btakita/rr/issues#issue/17

于 2010-01-04T22:50:52.517 回答