views:

259

answers:

1

I have the following RSpec example which is passing:

describe UsersController  do
  it "should render new template on new action" do
    get :new
    response.should render_template("users/new")
  end
end

The problem is I have not implemented the 'new' action on the UsersController. Can anyone tell me why this test is passing? I am new to RSpec, so any tips would be greatly appreciated!

+1  A: 

When requesting an action for which a view exists, but the action is not defined, Rails will simply render the view. Therefore your spec (correctly) passes.

In addition to this spec, you may want to test for the assignment of particular instance variables. Example:

it "should assign the found articles for the view" do
  assigns[:article].should == [@article]
end
molf
Why then when I browse to "/users/new" do I receive "Unknown actionNo action responded to new." ?
Lee