-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
If I define let(:message) { mock_model(Message).as_null_object } and have an example that asserts my controller should redirect_to then I receive a wrong number of arguments (1 for 0) error. I'm using ruby 1.9.1p429, rails 3.0.0.rc and rspec-rails 2.0.0.beta.19
RSpec delegates redirect_to to Rails’ assert_template. In Ruby-1.9, we rely on Minitest instead
of Test::Unit, and its Assertions module is mixed in, and that module has a message method in
it. The let method defines a method, whose name is derived from the name passed to it: in this
case, message. That message method overrides the message method in Minitest::Assertions,
and thus, the error you see is created.
Here's a failing example:
require 'spec_helper'
describe MessagesController do
let(:message) { mock_model(Message).as_null_object }
describe "POST create" do
it "redirects to the Messages index" do
Message.stub(:new).and_return(message)
post :create
response.should redirect_to(:action => "index")
end
end
end
Metadata
Metadata
Assignees
Labels
No labels