Edit 1
I created an issue for rspec-rails and made a repo so people can test it themselves.
Original post
I've build a plugin according to this stackoverflow answer and added a route in my engine as follows:
# /config/routes.rb
Myplugin::Engine.routes.draw do
root to: 'pages#index'
end
My only rspec test is this:
# /spec/controllers/pages_controller_spec.rb
require "spec_helper"
describe Myplugin::PagesController do
describe "GET /admin" do
it "routes to pages#index" do
expect(get: "/admin").to route_to(controller: "pages", action: "index")
end
end
end
And in my dummy app I have this route:
# /spec/dummy/config/routes.rb
Rails.application.routes.draw do
mount Myplugin::Engine => "/admin"
end
I'm getting this error when running rspec
in the root of the plugin:
Failures:
1) Myplugin::PagesController GET /admin routes to pages#index
Failure/Error: expect(get: "/admin").to route_to(controller: "pages", action: "index")
No route matches "/admin"
# ./spec/controllers/pages_controller_spec.rb:8:in `block (3 levels) in <top (required)>'
I've tried this stackoverflow answer, but it doesn't change the output.
Any ideas?
I'm using rspec 2.13.0 and rails 3.2.13.