位于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_helper,所有我对关系的检查都会被定义两次......然后没有一个测试运行。
规格/ spec_helper:
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}
示例错误:*警告:'test:帐户应该有很多用户。 '已定义
但bundle exec rake test:units
命令的执行在开始运行实际测试时停止。 (与应该警告相同的错误)
注意:这是你在脚本/控制台中工作的方式:
Loading development environment (Rails 2.3.8)
>> require "spec"
=> []
>> include Spec::Matchers
=> Object
>> nil.should be_nil
=> true
>>
但是当我做的时候
require 'spec'
include Spec::Matchers
在测试助手中,我收到以下错误:
.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/optparse.rb:314:in `initialize': unhandled exception