使用rspec-rails
3.0+ 时,测试设置分为spec_helper
andrails_helper
我注意到生成spec_helper
的不是require 'rspec/rails'
.
这会导致 zeus 崩溃:
spec_helper.rb:5:in `<top (required)>': undefined method `configure' for RSpec:Module (NoMethodError)
对此问题最常见的回应是require 'rspec/rails'
.
但这不会破坏拆分仅使用 的铁轨规格和 PORO 规格的全部目的spec_helper
吗?或者这无关紧要,因为 Zeus 无论如何都预加载了 Rails?
我应该在我的 中做这样的事情spec_helper
吗?
# Zeus does not preload RSpec
require 'rspec/core' unless defined? RSpec.configure
请注意,在生成的rails_helper
包含:
ENV["RAILS_ENV"] ||= 'test'
require 'spec_helper'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
# Add additional requires below this line. Rails is not loaded until this point!