Why are my RSpec specs running twice?
- by James A. Rosen
I have the following RSpec (1.3.0) task defined in my Rakefile:
require 'spec/rake/spectask'
Spec::Rake::SpecTask.new(:spec) do |spec|
spec.libs << 'lib' << 'spec'
spec.spec_files = FileList['spec/**/*_spec.rb']
end
I have the following in spec/spec_helper.rb:
require 'rubygems'
require 'spec'
require 'spec/autorun'
require 'rack/test'
require 'webmock/rspec'
include Rack::Test::Methods
include WebMock
require 'omniauth/core'
I have a single spec declared in spec/foo/foo_spec.rb:
require File.dirname(__FILE__) + '/../spec_helper'
describe Foo do
describe '#bar' do
it 'be bar-like' do
Foo.new.bar.should == 'bar'
end
end
end
When I run rake spec, the single example runs twice. I can check it by making the example fail, giving me two red "F"s.
One thing I thought was that adding spec to the SpecTask's libs was causing them to be double-defined, but removing that doesn't seem to have any effect.