28

Hi I got lots of warning when run rspec which does annoying me too much,

How to fix it ? because I've tried the Ruby version 2.1.2 under rbenv, but it didn't work at all.

Here's my Gemfile

source 'https://rubygems.org'

gem 'bootstrap-sass'
gem 'coffee-rails'
gem 'rails'
gem 'haml-rails'
gem 'sass-rails'
gem 'uglifier'
gem 'jquery-rails'

group :development do
  gem 'sqlite3'
  gem 'pry'
  gem 'pry-nav'
  gem 'thin'
  gem "better_errors"
  gem "binding_of_caller"
end

group :test, :development do
    gem 'rspec-rails'
end

group :production do
  gem 'pg'
  gem 'rails_12factor'
end
gem 'hirb'
gem 'crack'
gem 'ap'
gem 'awesome_print'

# gem 'faker'

Warning meassages

% rspec                                                                                                                                             (git)-[feature/w1_test_the_video_model] 
nil
/Users/jeff/.rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.0/gems/bootstrap-sass-3.1.1.1/lib/bootstrap-sass/sass_functions.rb:20: warning: ambiguous first argument; put parentheses or even spaces
/Users/jeff/.rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.0/gems/sass-3.2.19/lib/sass/version.rb:5: warning: loading in progress, circular require considered harmful - /Users/jeff/.rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.0/gems/sass-3.2.19/lib/sass.rb
    from /Users/jeff/.rbenv/versions/2.0.0-p481/bin/rspec:23:in `<main>'
    from /Users/jeff/.rbenv/versions/2.0.0-p481/bin/rspec:23:in `load'
    from /Users/jeff/.rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.0/gems/rspec-core-3.0.0/exe/rspec:4:in `<top (required)>'
    from /Users/jeff/.rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.0/gems/rspec-core-3.0.0/lib/rspec/core/runner.rb:38:in `invoke'
    from /Users/jeff/.rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.0/gems/rspec-core-3.0.0/lib/rspec...
user3675188
  • 7,271
  • 11
  • 40
  • 76

3 Answers3

38

I had same error and fixed it refs the page.

Guard with RSpec on Rails 4 giving a lot of warnings

the --warnings option in the .rspec file by default. Remove that line, and the warnings will go away.

Community
  • 1
  • 1
isseium
  • 625
  • 4
  • 11
23

It's not a fix, but removing --warnings from your .rspec file makes the warnings "go away."

Basically, the --warnings flag puts ruby into verbose mode, which turns on alerts for a bunch of syntax issues that could potentially bite you later. Unfortunately, there's a lot of code out there (that you're probably using) that was never tested with warnings enabled. That means you're seeing a bunch of junk for code that isn't yours.

In this case, it looks like the sass gem has issues.

James Mason
  • 4,246
  • 1
  • 21
  • 26
  • 1
    I'd like to hide warnings from the gems that I use, so only the warnings from my own code are visible. Do you know if that's possible? – Dennis Jun 11 '14 at 19:24
0

These are warnings emitted by rspec because of a circular dependency. Likely this is a mix of require statements that are no longer correct. (I believe as of RSpec 3.0.)

If this is a Rails app:

  1. If your project is so old that you don't have a rails_helper.rb, you should use the rails g rspec:install to set this up. rails_helper.rb requires spec_helper, and it contains things that are specific to Rails.
  2. Make sure that your .rspec file includes --require 'rails_helper' and that it is checked in to source control.
  3. Remove any require 'spec_helper' or require 'rails_helper' from the top of any spec files.

If this is not a Rails app:

  1. Make sure that your .rspec file includes --require 'spec_helper' and that it is checked in to source control.
  2. Remove any require 'spec_helper' from the top of any spec files.

This will ensure that the dependencies are only loaded once, regardless of whether you run rspec on a specific file or for all of them.

Robin Daugherty
  • 7,115
  • 4
  • 45
  • 59