A
A
Anton Ivanov2017-05-25 19:26:48
Ruby on Rails
Anton Ivanov, 2017-05-25 19:26:48

How to write routes spec correctly?

Hello.
in routes.rb I have this:

authorized     = ->(request) { request.session[:user_id].present? }
  constraints authorized do
    get 'test' => 'test#test'
  end

if I check in the test like this: then, of course, it does not work, since there is no session. There is also a route , but it is not possible to call it from the test until the desired route is checked. There is also no request or @request variable. How can such a route be tested?
expect(get: '/test').to route_to('test#test')
post 'login'

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question