我在Rakefile中定义了以下RSpec(1.3.0)任务:
require 'spec/rake/spectask' Spec::Rake::SpecTask.new(:spec) do |spec| spec.libs << 'lib' << 'spec' spec.spec_files = FileList['spec/**/*_spec.rb'] end
我在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'
我在spec / foo / foo_spec.rb中声明了一个spec:
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
当我运行rake spec时,单个例子运行两次.我可以通过示例失败来检查,给我两个红色的“F”.
解决方法
我有这个问题使用zeus,并从我的spec_helper.rb中删除require’rails / autorun’阻止了我