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 => /[^/]+/
}

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs