Rspec.describe的未初始化的常量Rspec(Nameerror)

时间:2015-02-04 03:58:57

标签: ruby-on-rails rspec

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

top (required) : uninitialized constant Rspec (NameError)

这是模型测试失败,除非我删除' 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

我知道最好使用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

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

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

感谢您提供任何答案/建议。

1 个答案:

答案 0 :(得分:5)

你有一个拼写错误

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

RSpec,而不是Rspec。请注意大写S

相关问题