API for uni-directional routing expectations #221

Closed
dchelimsky opened this Issue Sep 29, 2010 · 5 comments

Comments

Projects
None yet
2 participants
@dchelimsky
Member

dchelimsky commented Sep 29, 2010

route_to delegates to assert_routing, which only passes if assert_generates and assert_recognizes would both pass. The Rails-3 router lets us define routes that are recognizable, but not generated. The simplest example is:

root :to => "projects#index"

In this case, this passes:

assert_recognizes({:controller => "projects", :action => "index"}, {:method => "get", :path => "/"})

But this fails:

assert_generates("/",{:controller => "projects", :action => "index"})

Therefore, these both fail:

assert_routing("/",{:controller => "projects", :action => "index"})
(:get => "/").should route_to({:controller => "projects", :action => "index"})

See http://groups.google.com/group/rspec/browse_thread/thread/50b46ca3e4bd3a78/2a60d77662a1ec31 for a lengthy discussion on this topic.

@dchelimsky

This comment has been minimized.

Show comment
Hide comment
@dchelimsky

dchelimsky Oct 6, 2010

Member

After more thought, I'm going to make route_to delegate to assert_recognizes instead of assert_routing. Generation is something that rails knows how to do, so at that point we're spec'ing rails.

Member

dchelimsky commented Oct 6, 2010

After more thought, I'm going to make route_to delegate to assert_recognizes instead of assert_routing. Generation is something that rails knows how to do, so at that point we're spec'ing rails.

@dchelimsky

This comment has been minimized.

Show comment
Hide comment
@dchelimsky

dchelimsky Oct 6, 2010

Member

route_to delegates to assert_recognizes rather than assert_routing

  • aligns better with the matcher name
  • eliminates failures on alternate routes to same controllers
  • route generation can be spec'd in the context of view specs
  • Closed by b45d093.
Member

dchelimsky commented Oct 6, 2010

route_to delegates to assert_recognizes rather than assert_routing

  • aligns better with the matcher name
  • eliminates failures on alternate routes to same controllers
  • route generation can be spec'd in the context of view specs
  • Closed by b45d093.
@jensb

This comment has been minimized.

Show comment
Hide comment
@jensb

jensb Mar 14, 2011

This should be documented properly, the publicly available docs still speak about "delegating to assert_routing". I spent hours trying to fix bugs in my app that weren't there ... :-(

How do I test route generation then with RSpec? I have some fairly complicated SEO routes (with multiple constraints) that need to be tested both ways.

jensb commented Mar 14, 2011

This should be documented properly, the publicly available docs still speak about "delegating to assert_routing". I spent hours trying to fix bugs in my app that weren't there ... :-(

How do I test route generation then with RSpec? I have some fairly complicated SEO routes (with multiple constraints) that need to be tested both ways.

@dchelimsky

This comment has been minimized.

Show comment
Hide comment
@dchelimsky

dchelimsky Mar 14, 2011

Member
@jensb

This comment has been minimized.

Show comment
Hide comment
@jensb

jensb Mar 15, 2011

Actually, it was http://www.ruby-forum.com/topic/212050, via Google.

Maybe I should put less trust into old forum posts. :-)

jensb commented Mar 15, 2011

Actually, it was http://www.ruby-forum.com/topic/212050, via Google.

Maybe I should put less trust into old forum posts. :-)

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment