Ruby on rails 我如何让规范匹配者处理我的测试?目前,我得到了一堆;“已定义”;错误

Ruby on rails 我如何让规范匹配者处理我的测试?目前,我得到了一堆;“已定义”;错误,ruby-on-rails,testing,Ruby On Rails,Testing,在test_helper.rb的顶部 require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'test_help' require "bundler/setup" Bundler.require(:test) require 'spec' require 'spec/spec_helper' require 'factory_girl' require 'shoulda' req

在test_helper.rb的顶部

require File.expand_path(File.dirname(__FILE__) + "/../config/environment")

require 'test_help'
require "bundler/setup"
Bundler.require(:test)

require 'spec'
require 'spec/spec_helper'
require 'factory_girl'
require 'shoulda'
require "shoulda-matchers"
require 'spec/expectations'


require 'test/shared_test.rb'
require 'test/attribute_sets.rb'
require 'test/functional/api/visibility_tests'
require 'test/functional/api/common_actions_tests'
require "json"
但是当我包含spec/spec\u helper时,我所有的shoulda关系检查都会被定义两次。。。然后没有一个测试运行

等级库/等级库辅助对象:

ENV["RAILS_ENV"] ||= 'test'
require File.expand_path(File.join(File.dirname(__FILE__),'..','config','environment'))
require 'spec/autorun'
require 'spec/rails'
require 'webrat'

Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
示例错误:*警告:“测试:帐户应具有多个用户。”已定义

但是
bundle exec rake test:units
命令的执行在开始运行实际测试时停止。(与shoulda警告相同的错误)

注意:这是如何让它在脚本/控制台中工作的:

Loading development environment (Rails 2.3.8)
>> require "spec"
=> []
>> include Spec::Matchers
=> Object
>> nil.should be_nil
=> true
>> 
但当我这么做的时候

require 'spec'
include Spec::Matchers
在test helper中,我得到以下错误:

.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/optparse.rb:314:in `initialize': unhandled exception

只是一个想法(所以还不是答案)-尝试删除require-shoulda's,我不确定是否需要它们,或者rspec是否会让你。。。哦,你没有使用rspec吗?很抱歉虽然那也会有帮助。评论“该做的事”并没有做任何事。另外,我不确定我是否在“使用”rspec。。。这是我的档案。。。但我只是不知道发生了什么事=\我相信你没有使用rspec,因为你没有它的宝石。您可能希望添加它并开始使用它,因为我认为您会发现关于测试的许多最有用的文档都是关于使用rspecIt的,它包含在GEM文件中。。。。但是我和我的环境有太多的冲突,在这一点上,我觉得最好的办法就是删除所有不起作用的东西,并找到另一种方法来做=\