ruby - Rails 5 Rspec ActionController::UrlGenerationError -


searched through other similar questions on here, , seem related malformed request of sort (not providing id, or not including params correctly) don't seem problem i'm having.

the route exists, going route in browser works fine. page loads, everything. rspec giving me urlgenerationerror reason.

i've tried manually specifying controller name in routes, changing pluralized controller, , using different (pluralized) controller. it's seeming there issue other configuration somewhere, error it's urlgeneration error extremely unhelpful. appreciate other ideas.

we have api controller specs elsewhere in our app seem functioning correctly, cannot tell difference in set between , one.

my error:

  1) spaceman::reputationenhancementscontroller show has 200 status code      failure/error: :show       actioncontroller::urlgenerationerror:        no route matches {:action=>"show", :controller=>"spaceman/reputation_enhancements"}      # ./spec/controllers/spaceman/reputation_enhancements_controller_spec.rb:10:in `block (3 levels) in <top (required)>'  finished in 1.14 seconds (files took 6.13 seconds load) 1 example, 1 failure  failed examples:  rspec ./spec/controllers/spaceman/reputation_enhancements_controller_spec.rb:9 # spaceman::reputationenhancementscontroller show has 200 status code 

routes:

spaceman::engine.routes.draw   resource :reputation_enhancement, path: "reputation-enhancement", only: [ :show, :create ]     :filter   end end 

test: (i've tried added type: :controller here, qualifying, adding rspec.describe instead, etc...)

require "rails_helper"  describe spaceman::reputationenhancementscontroller    describe "get show"     "has 200 status code"       :show       expect(response.status).to eq(200)     end   end  end 

rake routes

filter_reputation_enhancement    /reputation-enhancement/filter(.:format) spaceman/reputation_enhancements#filter        reputation_enhancement    /reputation-enhancement(.:format)        spaceman/reputation_enhancements#show                               post   /reputation-enhancement(.:format)        spaceman/reputation_enhancements#create 

edit:

i've tried manually specifying controller name in routes, changing pluralized controller, , using different (pluralized) controller. it's seeming there issue other configuration somewhere, error it's urlgeneration error extremely unhelpful. appreciate other ideas.

you're using singular resource in routes spec requesting plural form “reputation_enhancements”.

see this bit in routing guide singular resources , this long standing issue in rails issue tracker explains there's no way url_for map singular resource.

to resolve it, either specify path in spec or add plural route.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -