rspec not detected in some projects

One of my projects does not detect rspec when I use require "spec_helper" in my spec files, but does detect rspec if I require "spec/spec_helper", which causes all my specs to fail. The end result is that I cannot run individual spec files or individual ("focused") examples within RubyMine.

Other projects do not have this problem.  More details:

  • Running the spec rake task works fine.
  • Running cucumber features via right-click/CMD+OPT+F8 works fine.
  • Failing project is Ruby 1.9.2-p136, Rspec 2.5.0
  • Succeeding project is Ruby 1.8.7, Rspec 2.5.0



Please see the screenshots for more details.  Any pointers would greatly appreciated!
no spec-1.jpg


error.jpg

gems.jpg

1 comment
Comment actions Permalink

Fixed!  This was really weird.  

We found that the Rspec detection/right-click-to-run button would disappear when required spec_helper.

We are using the cancan gem, which includes a matchers.rb file with Rspec matchers.  spec_helper.rb was requiring this helper.

# spec/spec_helper.rb

ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'cancan/matchers ## line of death
...



cancan/matchers looks like this:

# cancan-1.5.1/lib/cancan/matchers.rb
RSpec = Spec unless defined? RSpec # for RSpec 1 compatability ## line of death!!
RSpec::Matchers.define :be_able_to do |*args|
   ...
end



Removing the highlighted fixes RSpec running.  

Interestingly, we do not need require cancan/matchers anyway.

-- Joe
0

Please sign in to leave a comment.