A
A
Alexander Gonchurin2014-09-24 22:06:33
Ruby on Rails
Alexander Gonchurin, 2014-09-24 22:06:33

How to solve the problem with Rspec tests and routes (routes)?

Here is my routes.rb piece:

resources :users
match '/signup',  to: 'users#new',            via: 'get'

Passing a simple test gives an error:
Failure/Error: before { visit signup_path }
     ActionView::Template::Error:
      <b> arguments passed to url_for can't be handled. Please require routes or provide your own implementation</b>

Some problem with the definition of paths, the rake routes command issues:
Prefix Verb          URI Pattern               Controller#Action
users GET          /users(.:format)          users#index
 POST           /users(.:format)          users#create
new_user GET      /users/new(.:format)      users#new
edit_user GET       /users/:id/edit(.:format) users#edit
...
signup GET    /signup(.:format)         users#new

As I understand it, there is a path conflict (users#new). Although with a similar method in the Rails Tutorial, tests passed.
What's wrong with living?
Thanks in advance

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene Burmakin, 2014-09-24
@Freika

I'm not sure if this will solve the problem, but in general in Rails 4 match is considered deprecated. Use
get '/signup', to: "controller#action"

@
@proffard, 2014-09-29
_

The error is not related to routes, but to the fact that the tests do not include a module that knows the names of named routes.
Try to add a line to your test
, if it helps, then solve the problem globally by adding it to spec_helper.rb

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question