class InvitationsController < ApplicationController
def accept
end
end
describe InvitationsController do
describe “POST ‘accept’” do
it “should be successful” do
post :accept, :id => 1
response.should be_success
end
end
end
When I run this spec, I get:
No route matches {:controller=>“invitations”, :action=>“accept”,
:id=>“1”}
Can anyone please suggest what I should be writing instead to test this
request?
On Sat, Sep 26, 2009 at 1:56 AM, Giuseppe B. [email protected]
wrote:
Pretty please?
Huh? Pretty please what? Matt and I have both responded. In my case I
asked you about the versions you have. You didn’t quote any of the
previous posts in this thread, so I have no idea what you’re asking
for at this point. Did you receive our responses?
Huh? Pretty please what? Matt and I have both responded. In my case I
asked you about the versions you have. You didn’t quote any of the
previous posts in this thread, so I have no idea what you’re asking
for at this point. Did you receive our responses?
So sorry, I must be missing something.
I am looking right now at this page:
I’m wondering–am I looking at the wrong forum page? But then, why do I
see your latest response (and received the email notification I
requested), but not the previous?
Sorry for the trouble, I would appreciate if you could point me to the
proper URL, if this is the problem.
On Sat, Sep 26, 2009 at 8:10 AM, Giuseppe B. [email protected]
wrote:
Huh? Pretty please what? Matt and I have both responded. In my case I
asked you about the versions you have. You didn’t quote any of the
previous posts in this thread, so I have no idea what you’re asking
for at this point. Did you receive our responses?
So sorry, I must be missing something.
I am looking right now at this page:
Well - that should be one of two correct URLs. The forum is mirrored
w/ a google group. I see there are posts missing from the forum, but I
see all the posts in the google group:
Well - that should be one of two correct URLs. The forum is mirrored
w/ a google group. I see there are posts missing from the forum, but I
see all the posts in the google group
Yes, now I see, thanks.
So, back to the original issue, I have rails 2.3.4, rspec 1.2.8, rspec-
rails 1.2.7.1, ruby 1.8.6 (universal darwin9.0)
I too have created a new app with only the above-mentioned code added
to the rails-generated and rspec-generated stuff. I am still getting
the “No route matches…” error
I have posted the app here:
git://github.com/giuseb/spec_named_route.git
I am somewhat nervous that this is going to turn out a silly mistake
on my part as Matt suggested, but still…
We don’t offer much help, as Matt doesn’t see a problem and I can’t
reproduce it - but at least we tried to play
I’ll take a turn! Helps me procrastinate on my own stuff. >8->
Giuseppe: have you tried running ‘rake routes’ to see what the
application thinks you valid routes are? Reconciling that with what’s
going on in routes.rb is a good next step.
Also, when testing behavior has me stumped, I often remember far too
late to open up my Web browser and poke at the pages directly, as a
human being. I’ll often see error messages that way that RSpec
doesn’t think to show me, or I can view source and see what the links
in my form really are.
Those aren’t direct answers (I’m with Matt, I don’t see anything wrong
here unless something else in routes.rb is conflicting with the line
you posted) but they’ve been useful tactics for me in the past.
So, back to the original issue, I have rails 2.3.4, rspec 1.2.8, rspec-
on my part as Matt suggested, but still…
Giuseppe
Thanks for posting the app - that was very helpful.
I’ve got good news and bad news: The good news is that I hadn’t set up
my routes as cleanly as yours, and when I did I was able to reproduce
the error.
The bad news is that this is a deficiency the underlying Rails testing
framework that rspec-rails wraps. I tried the same example in a rails
functional test and got the same failure:
class InvitationsControllerTest < ActionController::TestCase
test “the post accept invitation should be successful” do
get :accept, :id => “1”
assert_response :success
end
end
test_the_post_accept_invitation_should_be_successful(InvitationsControllerTest):
ActionController::RoutingError: No route matches {:action=>“accept”,
:controller=>“invitations”, :id=>“1”}
/test/functional/invitations_controller_test.rb:6:in
`test_the_post_accept_invitation_should_be_successful’
Giuseppe: have you tried running ‘rake routes’ to see what the
application thinks you valid routes are? Reconciling that with what’s
going on in routes.rb is a good next step.
The following line is the whole of the ‘rake routes’ output:
Also, when testing behavior has me stumped, I often remember far too
late to open up my Web browser and poke at the pages directly, as a
human being.
I did visit: http://localhost:3000/accept_invitation/1
and the request gets properly routed by the app.
As David pointed out earlier today, this behavior appears to be
related to rails’ testing framework, rather than to rspec.