0

I have the following rspec code:

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

It passes successfully as written (RR syntax commented out) but when I switch to the RR syntax it fails with:

'ProjectsController creating a new project should redirect to project with a notice on successful save' FAILED expected new_record? to return false, got true

What is the difference between the two that RR would fail?

Vega
  • 27,856
  • 27
  • 95
  • 103
Jason
  • 1
  • 2

1 Answers1

0

It appears the difference is that you can't call instance_of twice with rr.

EDIT: this may no longer be the case, see https://github.com/rr/rr#class-instances

sandstrom
  • 14,554
  • 7
  • 65
  • 62
Jason
  • 1
  • 2