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

  • SEARCH
  • Home
  • 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 6580033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:58:25+00:00 2026-05-25T15:58:25+00:00

I started making a Rails 3.1 engine, and I’m having a hard time testing

  • 0

I started making a Rails 3.1 engine, and I’m having a hard time testing it using rspec.

First of all, if I run rails g integration_test whatever it creates a regular integration test in tests/integration instead of spec/requests (the rspec-rails gem is installed and required as a development dependency in the gemspec file)

Also, when I run a spec test I get an error saying the table corresponding to the model I’m testing has not been created. I tried rake engine_name:install:migrations and running rake db:migrate from inside the dummy app, and I get a “table already exists” error.

Everything just seems disconnected, I feel I’m missing something here to make the rspec gem work seamlessly as it usually does with full rails applications.

I followed all the changes from here http://rubyx.com/2011/03/01/start-your-engines and I can test the engine manually by launching the dummy app via the console as shown here http://railscasts.com/episodes/277-mountable-engines.

Is there a way to make rspec the default for testing a rails 3.1 engine?

  • 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-05-25T15:58:26+00:00Added an answer on May 25, 2026 at 3:58 pm

    I am using RSpec with a Rails engine without issues.

    I created my plugin using the following switches: -T –full –dummy-path=spec/dummy.

    • -T excludes test/unit
    • --full indicates that the plugin is an engine
    • --dummy-path is simply so that we don’t get a test directory (the
      default is test/dummy).

    From there I used the spec_helper from the “start your engines” article:

    # Configure Rails Envinronment
    ENV["RAILS_ENV"] = "test"
    require File.expand_path("../dummy/config/environment.rb",  __FILE__)
    
    require 'rspec/rails'
    
    ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
    
    # Requires supporting ruby files with custom matchers and macros, etc,
    # in spec/support/ and its subdirectories.
    Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f }
    
    RSpec.configure do |config|
      config.use_transactional_fixtures = true
    end
    

    For the generators. I add a config.generators block to my engine.rb file like so:

    module MyEngine
      class Engine < Rails::Engine
        config.generators do |g|
          g.test_framework :rspec, :view_specs => false
        end
      end
    end
    

    With that, I’m able to get rspec tests when running a generator like the model generator.

    As for the DB, is your database.yml file set up correctly? Did you load the test environment, e.g. rake db:test:clone or rake db:migrate RAILS_ENV=test? My guess is that RSpec can’t see your tables because there isn’t a test database set up.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been reading some tutorials on how to get started using Rails 2.0. (Time
I started making a 3d game. then I stopped for a some time and
Recently i started making a item container, and every time the user tries to
I have just started making web pages and I'm having lots of trouble with
I have started making graphics for my Android app using Adobe Photoshop. But I
rails newbie here. I've started making a value based to-do list. So far I've
Hey guys, This is my first time making an app with any kind of
I've started making a Minesweeper game in vb.net using a dynamically created grid of
I'm having an issue making an app that plays music in rails. I can't
I'm following this tutorial about making an Ajax request on Rails: http://net.tutsplus.com/tutorials/javascript-ajax/using-unobtrusive-javascript-and-ajax-with-rails-3/ made _form

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.