Skip to content

Routing error in the mountable rails plugin application. #1304

Open
@joowh85

Description

@joowh85

In command line

rails plugin new ENGINE_NAME --dummy-path=spec/dummy --skip-test-unit --mountable

gemspec file

s.add_development_dependency 'rspec-rails'
s.add_development_dependency 'factory_girl_rails'

rails_helper.rb

require File.expand_path('../dummy/config/environment', __FILE__)

engine.rb

 config.generators do |g|
      g.test_framework      :rspec,        :fixture => false
      g.fixture_replacement :factory_girl, :dir => 'spec/factories'
end

Command line

rails g scaffold NAME name:string

And run 'rspec' in command

  1) Backend::ShopsController GET new assigns a new shop as @shop
     Failure/Error: get :new, {}, valid_session
     ActionController::UrlGenerationError:
       No route matches {:action=>"new", :controller=>"backend/shops"}
     # /home/sangwoojoo/.rvm/gems/ruby-2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/journey/formatter.rb:46:in `generate'
     # /home/sangwoojoo/.rvm/gems/ruby-2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:710:in `generate'
     # /home/sangwoojoo/.rvm/gems/ruby-2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:741:in `generate'
     # /home/sangwoojoo/.rvm/gems/ruby-2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:736:in `generate_extras'
     # /home/sangwoojoo/.rvm/gems/ruby-2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:731:in `extra_keys'
     # /home/sangwoojoo/.rvm/gems/ruby-2.2.0/gems/actionpack-4.2.0/lib/action_controller/test_case.rb:205:in `assign_parameters'
     # /home/sangwoojoo/.rvm/gems/ruby-2.2.0/gems/actionpack-4.2.0/lib/action_controller/test_case.rb:616:in `process'
     # /home/sangwoojoo/.rvm/gems/ruby-2.2.0/gems/actionpack-4.2.0/lib/action_controller/test_case.rb:65:in `process'
     # /home/sangwoojoo/.rvm/gems/ruby-2.2.0/gems/actionpack-4.2.0/lib/action_controller/test_case.rb:505:in `get'
     # ./spec/controllers/backend/shops_controller_spec.rb:58:in `block (3 levels) in <module:Backend>'

  2) Backend::ShopsController routing routes to #index
     Failure/Error: expect(:get => "/shops").to route_to("shops#index")
       No route matches "/shops"
     # ./spec/routing/backend/shops_routing_spec.rb:8:in `block (3 levels) in <module:Backend>'

  3) Backend::ShopsController routing routes to #new
     Failure/Error: expect(:get => "/shops/new").to route_to("shops#new")
       No route matches "/shops/new"
     # ./spec/routing/backend/shops_routing_spec.rb:12:in `block (3 levels) in <module:Backend>'

  4) Backend::ShopsController routing routes to #show
     Failure/Error: expect(:get => "/shops/1").to route_to("shops#show", :id => "1")
       No route matches "/shops/1"
     # ./spec/routing/backend/shops_routing_spec.rb:16:in `block (3 levels) in <module:Backend>'

  5) Backend::ShopsController routing routes to #edit
     Failure/Error: expect(:get => "/shops/1/edit").to route_to("shops#edit", :id => "1")
       No route matches "/shops/1/edit"
     # ./spec/routing/backend/shops_routing_spec.rb:20:in `block (3 levels) in <module:Backend>'

  6) Backend::ShopsController routing routes to #create
     Failure/Error: expect(:post => "/shops").to route_to("shops#create")
       No route matches "/shops"
     # ./spec/routing/backend/shops_routing_spec.rb:24:in `block (3 levels) in <module:Backend>'

  7) Backend::ShopsController routing routes to #update
     Failure/Error: expect(:put => "/shops/1").to route_to("shops#update", :id => "1")
       No route matches "/shops/1"
     # ./spec/routing/backend/shops_routing_spec.rb:28:in `block (3 levels) in <module:Backend>'

  8) Backend::ShopsController routing routes to #destroy
     Failure/Error: expect(:delete => "/shops/1").to route_to("shops#destroy", :id => "1")
       No route matches "/shops/1"
     # ./spec/routing/backend/shops_routing_spec.rb:32:in `block (3 levels) in <module:Backend>'

  9) shops/edit renders the edit shop form
     Failure/Error: @shop = assign(:shop, Shop.create!(
     NameError:
       uninitialized constant Shop
     # ./spec/views/backend/shops/edit.html.erb_spec.rb:5:in `block (2 levels) in <top (required)>'

  10) shops/index renders a list of shops
     Failure/Error: Shop.create!(
     NameError:
       uninitialized constant Shop
     # ./spec/views/backend/shops/index.html.erb_spec.rb:6:in `block (2 levels) in <top (required)>'

  11) shops/new renders new shop form
     Failure/Error: assign(:shop, Shop.new(
     NameError:
       uninitialized constant Shop
     # ./spec/views/backend/shops/new.html.erb_spec.rb:5:in `block (2 levels) in <top (required)>'

  12) shops/show renders attributes in <p>
     Failure/Error: @shop = assign(:shop, Shop.create!(
     NameError:
       uninitialized constant Shop
     # ./spec/views/backend/shops/show.html.erb_spec.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.02859 seconds (files took 1.01 seconds to load)
29 examples, 12 failures, 17 pending

Failed examples:

rspec ./spec/controllers/backend/shops_controller_spec.rb:57 # Backend::ShopsController GET new assigns a new shop as @shop
rspec ./spec/routing/backend/shops_routing_spec.rb:7 # Backend::ShopsController routing routes to #index
rspec ./spec/routing/backend/shops_routing_spec.rb:11 # Backend::ShopsController routing routes to #new
rspec ./spec/routing/backend/shops_routing_spec.rb:15 # Backend::ShopsController routing routes to #show
rspec ./spec/routing/backend/shops_routing_spec.rb:19 # Backend::ShopsController routing routes to #edit
rspec ./spec/routing/backend/shops_routing_spec.rb:23 # Backend::ShopsController routing routes to #create
rspec ./spec/routing/backend/shops_routing_spec.rb:27 # Backend::ShopsController routing routes to #update
rspec ./spec/routing/backend/shops_routing_spec.rb:31 # Backend::ShopsController routing routes to #destroy
rspec ./spec/views/backend/shops/edit.html.erb_spec.rb:10 # shops/edit renders the edit shop form
rspec ./spec/views/backend/shops/index.html.erb_spec.rb:15 # shops/index renders a list of shops
rspec ./spec/views/backend/shops/new.html.erb_spec.rb:10 # shops/new renders new shop form
rspec ./spec/views/backend/shops/show.html.erb_spec.rb:10 # shops/show renders attributes in <p>

How can I fix this?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions