mbdev
mbdev

Reputation: 6583

How to write rspec test for custom routes

I have the following custom route:

match '/boeing-737', controller: :planes, action: :display, id: 1000

The 'get' method in rspec only accepts action name, but doing this:

get :display, id: 1000

I am getting:

RoutingError: No route matches {:id=>"1000", :controller=>"planes", :action=>"display"}

And there is no option to do get '/boeing-737' in the test.

Upvotes: 2

Views: 1581

Answers (1)

mbdev
mbdev

Reputation: 6583

Found the solution, the id has to be string value, I will post it here since I think this use case is not documented enough in rspec:

match '/boeing-737', controller: :planes, action: :display, id: '1000'

Upvotes: 1

Related Questions