Rspec.describe上的单位化常量Rspec(名称错误)

rub*_*vel 2 rspec ruby-on-rails

当我运行我的测试时,我收到此错误:

top (required) : uninitialized constant Rspec (NameError)
Run Code Online (Sandbox Code Playgroud)

这是模型测试失败,除非我删除'Rspec'.

ROOT_APP /规格/型号/文件/ date_spec.rb:

require 'rails_helper'

Rspec.describe Document::Date, :type => :model do
  pending "add some examples to (or delete) #{__FILE__}"
end
Run Code Online (Sandbox Code Playgroud)

我知道最好使用Rspec.describe而不是describe.(关于猴子修补的东西,不确定这是什么).

当然我可以单独使用describe,这就是我现在正在做的只是让我的测试工作.我只想更多地了解可能发生的事情.

全部在ROOT_APP/spec目录下:

rails_helper.rb

ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'spec_helper'

require 'factory_girl'
require 'capybara/rspec'
require 'capybara/rails'

  Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }

RSpec.configure do |config|

  config.infer_spec_type_from_file_location!

  config.include(MailerMacros)
  config.before(:each) { reset_email }

  config.filter_run :focus => true
  config.run_all_when_everything_filtered = true
  config.include FactoryGirl::Syntax::Methods
end
Run Code Online (Sandbox Code Playgroud)

spec_helper.rb

RSpec.configure do |config|

config.expect_with :rspec do |expectations|  
  expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end

  config.mock_with :rspec do |mocks|
    mocks.verify_partial_doubles = true
  end
end
Run Code Online (Sandbox Code Playgroud)

我尝试将spec_helper代码放入rails_helper.rb文件中,因此只有一个文件,我得到了同样的错误.

谢谢你的任何答案/建议.

Aru*_*hit 5

你有一个错字:

RSpec.describe Document::Date, :type => :model do
  pending "add some examples to (or delete) #{__FILE__}"
end
Run Code Online (Sandbox Code Playgroud)

RSpec不是Rspec.注意上如果s.