This project is archived and is in readonly mode.
[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:in
test/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
-
MatthewRudy April 15th, 2010 @ 06:18 AM
- Assigned user set to Santiago Pastorino
I don't know if this is the right answer...
but...
it broke my tests..Like I say,
perhaps the answer is not to include these assertions
but as it stands the assertions exist
but will not work
unless we do thesetup do @routes = :blah end
Alternatively
we could add an exception
explaining this hack
to the assertion -
Santiago Pastorino April 23rd, 2010 @ 12:27 AM
- State changed from new to invalid
assert_recognizes doesn't make sense on an IntegrationTest use it in Functional tests
-
Santiago Pastorino April 23rd, 2010 @ 01:01 AM
- State changed from invalid to open
Perhaps it's not the best use case but should work. Need more discussion here
-
MatthewRudy April 23rd, 2010 @ 07:03 AM
I agree it may not make sense,
but it seems wrong that the method is included,
but is guaranteed to break.I've got another fix in my head
give me a mo,
I'll attach another patch. -
Santiago Pastorino April 23rd, 2010 @ 02:16 PM
- Milestone cleared.
Matthew Rudy I have a solution but i'll wait i want to apply yours ;)
-
MatthewRudy April 24th, 2010 @ 05:20 PM
sorry Santiago
I am in Taipei,
didnt have internet to upload my patch.I'd like to see you solution,
but here's minebasically I decided that the line in the assertion which assumes "@routes" is set
can just throw an exception if its not
and suggest adding the @routes = ...attached as a patch
and on githubhttp://github.com/matthewrudy/rude-rails/commit/c333d0bea336f1ecf8a...
http://github.com/matthewrudy/rude-rails/tree/make-assert-recognise... -
Santiago Pastorino April 24th, 2010 @ 11:29 PM
- Assigned user changed from Santiago Pastorino to Jeremy Kemper
MatthewRudy here is the fix, i've made with your name ;) http://github.com/spastorino/rails/commit/ed1aa8e0bd33480cb2d10942d... and here are the tests http://github.com/spastorino/rails/commit/7e5e9338a6e9f85df1506c843...
Let's wait for Jeremy revision.
Thank you!. -
Repository April 24th, 2010 @ 11:45 PM
- State changed from open to committed
(from [5c9d23f870bc59a42a2c5994f4e6b11d3e4e5bdc]) Make assert_recognizes work in IntegrationTest [#4390 state:committed]
Signed-off-by: Santiago Pastorino santiago@wyeworks.com
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/5c9d23f870bc59a42a2c5994f4e6b1... -
Repository April 24th, 2010 @ 11:45 PM
(from [ed0ca5db9ea247ceae67f22a750cbd49006f35ed]) Add a test for assert_recognizes on ActionDispatch::IntegrationTest [#4390 state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/ed0ca5db9ea247ceae67f22a750cbd... -
Jeremy Kemper October 15th, 2010 @ 11:01 PM
- Milestone set to 3.0.2
- Importance changed from to Low
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>
People watching this ticket
Attachments
Referenced by
- 4390 [PATCH] assert_recognizes should work in Integration Tests (from [5c9d23f870bc59a42a2c5994f4e6b11d3e4e5bdc]) Make as...
- 4390 [PATCH] assert_recognizes should work in Integration Tests (from [ed0ca5db9ea247ceae67f22a750cbd49006f35ed]) Add a t...