Guard + Zeus + Rspec-Rails: undefined method 'configure' for Rspec:Module
Asked Answered
A

4

3

I'm using the following:

Rails 4.1.1
guard-zeus 2.0.0
rspec-rails 3.0.1

Out of box default rails g rspec:install and guard init

When I run guard and save a spec file, I get the error:

undefined method `configure` for RSpec:Module (NoMethodError)

I can run specs with rspec spec and rake just fine.

In spec_helper, if I require 'rspec/rails before the configure block, guard works fine, but then rspec spec fails with the error:

uninitialized constant ActiveSupport::Autoload (NameError)

I'm guessing there's a problem with load order now that rails_helper and spec_helper are separated.

Two questions:

  1. How can I fix this?
  2. Is there a different solution for continuous integration locally that you can recommend that works with latest Rails and Rspec.

You only have to answer one question.

Awildaawkward answered 19/9, 2014 at 18:6 Comment(1)
Could you show your spec_helper file and what line you are getting that error?Barnard
H
5

The following fix worked for me:

#spec/spec_helper.rb
require 'rspec/core'
Histology answered 1/6, 2015 at 12:36 Comment(2)
he doesn't need toVertebrate
Works for me. How did you know you had to run that?Eellike
B
3

Throwing out a quick answer that may be the problem. Your spec_helper file should have the following order:

ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'

rspec/rails needs to be required after the config/environment require.

Barnard answered 20/9, 2014 at 0:1 Comment(1)
Thank you for your info, I have the problem and I added your solutionAcrostic
A
2

The following:

undefined method `configure` for RSpec:Module (NoMethodError)

suggests you are are missing a

require 'rspec'

This normally isn't necessary, but if you put it in your spec/spec_helper.rb that should work.

(If you run RSpec directly, it's included already with RSpec).

The reason it's not included is perhaps:

  • you are not running guard through bundler

  • or your Gemfile does not have:

    gem 'rspec' # without the require: false
    
  • or something may be wrong with your .rspec file (which should be present)

The require 'rspec/rails' should probably go into the spec/rails_helper.rb...

... but a better way would be to update your rspec-rails gem and run:

rails generate rspec:install

and if you're prompted - used 'd' to differences (and ideally use the recommended changes).

Audiogenic answered 17/12, 2014 at 5:39 Comment(0)
P
1

You should add following require to top of file spec_helper.rb

require 'rspec/rails'

Take the reference here: Zeus GitHub issue 308

Polysynthetic answered 23/7, 2017 at 12:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.