[rspec-users] [rspec] looking for a simple refresher

Andrew WC Brown omen.king at gmail.com
Fri Aug 17 15:14:39 EDT 2007


I've been off the rspec for a few months and I'm trying to get back on it.

1)
Spec::Mocks::MockExpectationError in 'TicketsController handling POST
/tickets should create a new ticket'
Mock 'Ticket_1001' expected :new with ({}) once, but received it 0 times
./spec/controllers/tickets_controller_spec.rb:16:
script/spec:4:

class TicketsController < ApplicationController

  def new
    Ticket.new
  end

end

describe TicketsController, "handling POST /tickets" do

  before do
    @ticket = mock_model(Ticket, :to_param => '1', :save => true)
    Ticket.stub!(:new).and_return(@ticket)
    @params = {}
  end

  def do_post
    post :create, :ticket => @params
  end

  it "should create a new ticket" do
    @ticket.should_receive(:new).with(@params).and_return(@ticket)
    do_post
  end

end

Would someone provide with an explanation what I have to do to make this
spec pass?
Peepcode hasn't released their screen cast on rspecing controllers yet ='(
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070817/61e34fc1/attachment.html 


More information about the rspec-users mailing list