Running the tests for my plugin like this:
LOAD_PLUGINS=1 bundle exec rake plugin:spec["my-plugin"]
… the plugin’s routes don’t seem to be available in the following spec file:
spec/controllers/plugin/routes_controller_spec.rb
:
require 'rails_helper'
describe Plugin::RoutesController do
it 'should route to #index' do
expect(get '/plugin_routes').to route_to(action: :index, controler: 'plugin/routes')
end
end
Error:
ActionController::UrlGenerationError:
No route matches {:action=>"/plugin_routes", :controller=>"plugin/routes"}
What am I doing wrong? Below are excerpts of my plugin’s code:
plugin.rb
:
# …
Discourse::Application.routes.append do
get '/plugin_routes' => 'plugin/routes#index', constraints: AdminConstraint.new
end
app/controllers/plugin/routes_controller.rb
:
class Plugin::RoutesController < ApplicationController
def index
# …
end
end