This project is archived and is in readonly mode.

#4390 ✓committed
MatthewRudy

[PATCH] assert_recognizes should work in Integration Tests

Reported by MatthewRudy | April 14th, 2010 @ 05:57 AM | in 3.0.2

this was still working in beta1
(but broke in beta2... which I didn't get round to try)

anyway

here's the example of my use

class RoutingTest < ActionDispatch::IntegrationTest
  
  test "/projects" do
    assert_recognizes({:controller => "projects", :action => "index"}, "/projects")
    assert_recognizes({:controller => "projects", :action => "show", :id => "23"}, "/projects/23")
  end

end

I tend to do these routing tests as an integration test... as that's kind of what they are.
but since beta2 this gives the following error

Error:
test/projects(RoutingTest):
  NoMethodError: undefined method recognize_path' for nil:NilClass
  /test/integration/routing_test.rb:6:intest/projects'

As you can see this error is kind of obscure,
but comes from the fact that @routes is not set by default in an IntegrationTest

Its possible that this kind of test shouldn't be possible
(I'm kind of testing controller structure, whereas it could be argued that integration tests are supposed to be independent of this type of thing...)

I think either this patch should be applied
or the RoutingAssertions should not be included into IntegrationTest
(seems like a bad idea to have an assertion that will never work)

Anyway,
here is my patch
http://github.com/matthewrudy/rude-rails/commit/67f1f2340977d490a5f...
http://github.com/matthewrudy/rude-rails/tree/integration-tests-sho...

and attached also

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages