Route Error: NoMethodError: undefined method `values' for" / the / route ": String

I get an unsuccessful test, which is being debugged with great difficulty.

My test case:

it "routes to #active" do get ("/parties/active").should route_to("parties#active") end 

My route:

 resources :parties do get 'active', :on => :collection end 

When I run the test case, I get the following error:

 NoMethodError: undefined method `values' for "/parties/active":String 

Full error output: https://gist.github.com/1748264

When I start the rake routes, I see:

 active_parties GET /parties/active(.:format) parties#active parties GET /parties(.:format) parties#index POST /parties(.:format) parties#create new_party GET /parties/new(.:format) parties#new edit_party GET /parties/:id/edit(.:format) parties#edit party GET /parties/:id(.:format) parties#show PUT /parties/:id(.:format) parties#update DELETE /parties/:id(.:format) parties#destroy root / parties#show 

The test that I run is almost identical to the test for the new one created by scaffolding:

 it "routes to #new" do get("/parties/new").should route_to("parties#new") end 

Any idea what is going on?

+4
source share
2 answers

You put a space between get and arguments for the method. Do not do this.

You have the following:

 it "routes to #active" do get ("/parties/active").should route_to("parties#active") end 

When should it be:

 it "routes to #active" do get("/parties/active").should route_to("parties#active") end 

Otherwise, it will look like this:

  get(("/parties/active").should route_to("parties#active")) 
+5
source

Try using a hash style route:

 { :get => 'parties/new' }.should route_to('parties#new') 
+1
source

Source: https://habr.com/ru/post/1394922/


All Articles