Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8366267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:52:27+00:00 2026-06-09T12:52:27+00:00

I’ve created a Rails Engine in the normal fashion , installed RSpec, and generated

  • 0

I’ve created a Rails Engine in the normal fashion, installed RSpec, and generated a scaffold for a model, but I can’t get any routing specs to pass.

Here’s one example:

describe Licensing::LicensesController do
  it 'routes to #index' do
    get('/licensing/licenses').should route_to('licensing/licenses#index')
  end
end

I’m running the examples in the dummy app like this:

$ cd spec/dummy
$ rake spec
/Users/brandan/.rvm/rubies/ruby-1.9.3-p194/bin/ruby -S rspec ../routing/licensing/licenses_routing_spec.rb
F

Failures:

  1) Licensing::LicensesController routes to #index
     Failure/Error: get('/licensing/licenses').should route_to('licensing/licenses#index')
       No route matches "/licensing/licenses"
     # /Users/brandan/repos/licensing/spec/routing/licensing/licenses_routing_spec.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.04345 seconds
1 example, 1 failure

The engine is mounted correctly in the dummy app:

# spec/dummy/config/routes.rb
Rails.application.routes.draw do
  mount Licensing::Engine => "/licensing"
end

And I can go into the dummy app and fire up the console and get that route just fine:

1.9.3p194 :001 > app.get('/licensing/licenses')
  Licensing::License Load (0.3ms)  SELECT "licensing_licenses".* FROM "licensing_licenses" 
200
1.9.3p194 :002 > app.response.body
"<!DOCTYPE html>..."

There’s some discrepancy between the dummy app and RSpec, and I can’t figure out what it is. I’ve found several articles that claim to solve this problem, but none of them have helped, and several of them are specific to Rails 3.1:

  • Ryan Bigg’s article on generating and testing engines
  • Matthew Ratzloff’s article on testing engine routes in Rails 3.1
  • Stefan Wienert’s article on mountable engines
  • A mailing list message about testing routing helpers in Rails 3.2

Has anybody solved this problem in Rails 3.2/RSpec 2.10?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:52:28+00:00Added an answer on June 9, 2026 at 12:52 pm

    Update (2013-10-31)

    RSpec 2.14 now fully supports engine routes:

    module MyEngine
      describe ExampleController do
        routes { MyEngine::Engine.routes }
      end
    end
    

    Add it to all routing specs:

    # spec/spec_helper.rb
    config.include Module.new {
      def self.included(base)
        base.routes { Reportr::Engine.routes }
      end 
    }, type: :routing
    

    The best solution I’ve been able to find so far is explicitly setting the route set that will be used during the tests:

    RSpec.configure do |config|
      config.before(:each, type: :controller) { @routes = Licensing::Engine.routes }
      config.before(:each, type: :routing)    { @routes = Licensing::Engine.routes }
    end
    

    Then I had to rewrite my routing examples to omit the namespace:

    it 'routes to #index' do
      get('/licenses').should route_to('licensing/licenses#index')
    end
    

    This seems like a bit of a hack, but it does make sense. I’m not testing whether Rails is able to mount an engine at a particular path. I’m only testing that my engine has correctly set up its own routes. Still, I’d rather not have to overwrite an instance variable to make it happen.

    Here are another couple of good threads on this topic:

    • How to test routes in a Rails 3.1 mountable engine
    • How do I write a Rails 3.1 engine controller test in rspec?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I need to clean up various Word 'smart' characters in user input, including but
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.