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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:16:47+00:00 2026-06-12T06:16:47+00:00

I’m developing a Rails 3.1 engine and want to test it. I use RSpec

  • 0

I’m developing a Rails 3.1 engine and want to test it. I use RSpec for this, and everything works nicely, but when trying to use Spork, I have the problem that my helpers are not correctly reloaded.

I read a lot about a similar problem with models, and I came up with the following possible fix:

# my_engine/spec/spec_helper.rb

ActiveSupport::Dependencies.clear
ActiveRecord::Base.instantiate_observers

Dir[File.join(File.dirname(__FILE__), '..', 'app', 'helpers', '*.rb')].each do |file|
  require file
end

# my_engine/spec/dummy/config/environments/test.rb
Dummy::Application.configure do
  # ...
  config.cache_classes = !(ENV['DRB'] == 'true') # Ensure that classes aren't cached when using Spork.
  # ...
end

This works as far as it definitely is reloading ever helper file (I added a breakpoint to check this), but the changes are not reflected within the tests, only a restart of Spork does. Maybe it’s because helpers are modules, and the tests don’t rely on the module but on the classes that implement the modules, so the modules are properly reloaded but not properly mixed in??

At the time being, I’m just putting all intitializer code into the each_run block:

# Configure Rails Environment
ENV["RAILS_ENV"] = "test"

require File.expand_path("../dummy/config/environment.rb", __FILE__)
require 'rspec/rails'

Rails.backtrace_cleaner.remove_silencers!

# Load support files
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }

RSpec.configure do |config|
  config.use_transactional_fixtures = true

  config.treat_symbols_as_metadata_keys_with_true_values = true
  config.filter_run :focus => true
  config.run_all_when_everything_filtered = true
end
  • 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-12T06:16:49+00:00Added an answer on June 12, 2026 at 6:16 am

    I have done a lot of research about this topic, and I’ve written about in these two blog posts:

    • How to Develop Rails 3.1 Engines with Ease: Part I – The engine
    • How to Develop Rails 3.1 Engines with Ease: Part II – The gem

    Regarding especially to my question above: I can imagine that it didn’t work because I didn’t require 'rspec/autorun' in the Spork.prefork block, but I’m not completely sure.

    Here’s the spec_helper.rb for my current engine (which successfully reloads everything as needed):

    require 'rubygems'
    require 'spork'
    
    Spork.prefork do
      ENV["RAILS_ENV"] ||= 'test'
      require File.expand_path("../dummy/config/environment", __FILE__)
      require 'rspec/rails'
      require 'rspec/autorun'
    
      Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
    
      RSpec.configure do |config|
        config.use_transactional_fixtures = true
        config.fixture_path = "#{::Rails.root}/spec/fixtures"
        config.infer_base_class_for_anonymous_controllers = false
        config.treat_symbols_as_metadata_keys_with_true_values = true
        config.filter_run :focus => true
        config.run_all_when_everything_filtered = true
      end
    end
    
    Spork.each_run do
      # This code will be run each time you run your specs.
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I want to construct a data frame in an Rcpp function, but when I
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.