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 8562707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:47:19+00:00 2026-06-11T16:47:19+00:00

I have a Rails Engine meant to provide some models and controllers to a

  • 0

I have a Rails Engine meant to provide some models and controllers to a larger project of ours. There’s a pretty decent set of specs for the Engine, using a bunch of mocks and some full-scale models and controllers within the engine’s dummy app to make sure the Engine is doing what it’s supposed to and working with the larger application.

However, even with all tests passing, I frequently find broken behavior when I update the engine in the larger application. If my tests are passing but the behavior is broken, clearly something’s wrong with the tests, but what? Am I mocking too much, or not enough?

To get me closer to figuring this out, I’d like to be able to run the engine’s tests from inside the full application. This seems like it should be possible, but I don’t understand rspec thoroughly enough to get a handle on how.

(This is related to this question but not quite the same; I’m not trying to run all the specs from one command, just to run the engine’s specs within the full app environment. This also seems to be related. Actually, I’ve read every question tagged with both rspec and rails-engines–there aren’t many–and they’re all either not what I need, or unanswered.)

  • 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-11T16:47:21+00:00Added an answer on June 11, 2026 at 4:47 pm

    The simplest solution would be to specify the paths in rspec command. If you have directory structure

    /project
    /engine
    /engine_2
    

    Then you do and should run all the specs

    cd project
    rspec spec/ ../engine/spec ../engine_2/spec
    

    But if you want to run specs on Continous Integration or just this doesn’t seem to be comfortable I solved this problem with a customized rake spec task, changing the pattern method.

    lib/task/rspec.rake should look like this

    require "rspec/core/rake_task"
    
    RSpec::Core::RakeTask.new(:spec)
    
    task :default => :spec
    RSpec::Core::RakeTask.module_eval do
      def pattern
        extras = []
        Rails.application.config.rspec_paths.each do |dir|
          if File.directory?( dir )
            extras << File.join( dir, 'spec', '**', '*_spec.rb' ).to_s
          end
        end
        [@pattern] | extras
      end
    end
    

    In engine class you add a path to config.rspec_paths

    class Engine < ::Rails::Engine
      # Register path to rspec
      config.rspec_paths << self.root
    end
    

    And don’t forget to initialize config.rspec_paths somewhere in a base project.

    If you want to add factories then you can create initializer, you can find solution somewhere here on stackoverflow.

    Not sure if this solution is the best but works for me and I am happy with that. Good luck!

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

Sidebar

Related Questions

I have an engine which defines some models and controllers. I want to be
I have a Rails Engine and I want to access the parents models. Is
I'm writing a blog engine in rails, and have set up a tag model
I'm trying to set a testing framework for a rails engine. I have everything
I have a Rails engine that defines a class method top(count) on a model
I have Rails application with mounted Engine. #{main_app}/config/routes.rb mount CommentIt::Engine => /talk, :as =>
I have a engine style Rails plugin from which I can create a gem
I have rails application running in linode server .Some guy is continuously spamming (writing
Is there a way to have rails print out a number with commas in
I just started using CakePHP for a small project. I have rails experience, and

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.