Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Zeus sometimes runs RSpec twice #180

darthdeus opened this Issue · 23 comments

I'm not sure if this is a duplicate of #175, but I'm experiencing the same behavior in some of my apps that use RSpec.

However it doesn't happen in all of them, so I'm not sure how to give exact steps to reproduce this.


I'm having the same issue... Specs run twice when trying to run an individual spec file, but only run once when passing in a directory to the test command. This is with with the 13.1 gem.


Test frameworks do some really asinine hacks to autorun loaded test files. What version of rspec are you guys using? I'll try to figure this one out early next week.


I'm using rspec 2.12.1.


Thanks. I'll play with it on monday.


I'm using both 2.11 and having the issue exactly the same, twice when running a single spec, but only once when running all the specs.


Interestingly... I tested this on two projects, both using rspec 2.12.1 and both using zeus 0.13.1. In one project the specs run twice, and all fail the second time (it's like rspec's rails helpers aren't loaded during the second run). In the second project, everything works fine. I'm at a loss for what could be causing the issue.


In one project the specs run twice, and all fail the second time (it's like rspec's rails helpers aren't loaded during the second run)

I have same problem too.

zeus 0.13.1, rspec 2.12.0


It's running once for me when running against a directory, but twice when run against a single spec file.

On zeus 0.13.1, rspec 2.12.2.


Removing require 'rails/autorun' from my spec_helper.rb stops these errors from happening to me.

Including my spec_helper.rb for brevity. Note that this is basically from a fresh application, but I just did the same to an older app running rspec 2.8.0 and it seems to have worked.

require 'simplecov'

SimpleCov.start 'rails' do
  add_filter '/test/'
  add_filter '/config/'
  add_filter '/vendor/'
  add_filter '/spec/'

  add_group 'Controllers', 'app/controllers'
  add_group 'Models', 'app/models'
  add_group 'Helpers', 'app/helpers'
  add_group 'Decorators', 'app/decorators'
  add_group 'Libraries', 'lib'

  use_merging true

ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../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.fixture_path = "#{::Rails.root}/spec/fixtures"
  config.use_transactional_fixtures = true
  config.infer_base_class_for_anonymous_controllers = false
  config.order = "random"

I have to confirm this, but it only helps running the whole spec file.

If I try to run a specific line, I will get an error No tests found on line 69. Valid tests to run:, whereas with the autorun enabled I am able to run a single spec, but not the whole file.


In summary:
With rspec/autorun
directories run once
files run twice
running lines in tests works

Without rspec/autorun
directories never run (0 tests)
files run once (correctly)
running lines in tests doesn't work (not found, perhaps because 0 tests on the directory?)

(zeus master, rspec 2.12.0)

fwiw, when rspec runs twice, the second time my specs are failing due to database leftovers.

@burke any ideas on how to fix all this?


Interestingly, in the one project I have where Zeus (0.13.1) works perfectly with rspec (runs directories / single file, single file with line number), I am including "rspec/autorun" in my spec_helper.

In the project where I am experiencing problems with specs running twice, removing 'rspec/autorun' allows me to correctly run individual files and individual files with line numbers, but directories run no tests.


@Soliah 's fix works for me. I removed require 'rspec/autorun' from spec_helper. It was a remnant from the Spork days.


+1 for @Soliah

Mine worked as expected for both directories and files. Removing rspec/autorun from spec_helper.rb causes everything to run just once as expected.


While removing the rspec/autorun helps, it is still just treating the symptoms, not the root cause.


Removing rspec/autorun from spec_helper.rb worked for me.


Confirm that removing rspec/autorun solves the issue.


+1 about removing rspec/autorun.


As of 0.13.2, removing rspec/autorun solved this problem in all my projects!


Is there any hope for getting this fixed? :( I'd love to help, but not really sure how.


I believe it is fixed in 0.13.2. Updating my comment earlier:

Without rspec/autorun
directories run correctly (e.g. zeus rspec spec)
files run correctly (e.g. zeus rspec spec/models/user_spec.rb)
locations in tests run correctly (e.g. zeus rspec spec/models/user_spec.rb:23)

(zeus 0.13.2, rspec 2.12.1)


Btw, master is behind 0.13.2 at the moment: #236

@turadg turadg closed this in d3c096d

Removing rspec/autorun fixed the problem and still ensured tests run fine without Zeus

@rwjblue rwjblue referenced this issue in rails/spring

Issues with testing gems #83

@noahpatterson noahpatterson referenced this issue from a commit in noahpatterson/DCOpen211DCConnect
@monfresh monfresh Allow contributors to use Zeus for fast Rails commands & tests
[Zeus]( is a great gem that preloads
your Rails app so you can run commands and tests quickly. However,
it doesn't play well with the default "spec_helper.rb" that gets
generated when you install Rspec. The solution is to remove
"require 'rspec/autorun'" from "spec_helper.rb", which is what this
commit does.

This change does not affect those who do not have Zeus installed.
Running "rspec" from the command line will continue to work.

Reference and more info:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.