hwrd
hwrd

Reputation: 2180

Rspec 2.3 on Rails 3.0.3 giving some controller access problems?

It seems a bunch of my Rspec tests now fail after moving my application to Rspec 2.3 and Rails 3.0.3

An example is here:

it "should not be able to access 'destroy'" do
  delete :destroy
  response.should redirect_to(signin_path)
  flash[:error].should == "You must be signed in to view this page."
end

will give me the error:

1) FriendshipsController when not logged in: should not be able to access 'destroy'
 Failure/Error: delete :destroy
 No route matches {:controller=>"friendships", :action=>"destroy"}
 # ./spec/controllers/friendships_controller_spec.rb:21:in `block (3 levels) in <top (required)>'

In my routes.rb file, I've mapped the resources for this controller...

resources :friendships

Same for

get :edit
get :show
put :update

Only one that seems to work is

post :create

But this I cannot confirm 100%.

Any thoughts? Thanks for your time!

UPDATE:

get :new

also works and my UserSessions controller (Authlogic) doesn't seem to suffer from this problem. Nothing I've done different in my UserSessions controller, model, or test that I can tell.

Upvotes: 1

Views: 307

Answers (1)

ajmartin
ajmartin

Reputation: 2409

In the spec, try calling the method by:

delete :destroy, :id => "1"

Upvotes: 2

Related Questions