Phoenix Rising
2011-Apr-13 12:33 UTC
RSpec Routing Error: Expected block to return true value.
I''m doing some tests with rspec on a rails app and I have a setup where I''d like to match a URL like this: /search/users/name/servername To controller => search, action => users, with params of name and server. The issue is that I want to make sure people can just enter a name, without a server name at the end. Looking at the default comments in routes.rb, it''s obvious how to do the optional parameters (using () ). The problem I''m running into is it LOOKS like this may not be working. When I run the below test, I receive an error message stating "Expected block to return true value." This leads me to think that the block isn''t able to execute due to something being off in my route. Taking a look at the below code, does anyone have any ideas as to where I could be screwing up? Thanks. # in spec/routing/search_routing_spec.rb it "routes /search/users/foo/bar to search#users with name => foo, server => bar" do { :get => ''/search/users/foo/bar'' }.should route_to( :controller => "search", :action => "users", :name => "foo", :server => "bar" ) end # in routes.rb get ''/search/users/:name(/:server)'' => ''search#users'', :constraints => { :name => /[^\/]+/, :server => /[^\/]+/ } -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.