在文件规范/支持/ factory_girl.rb我有
fail "At least this file is being required"
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
end
我有一些规范代码
require 'pmc_article'
require 'pmc_article_parser'
require 'factory_girl'
require_relative './factories/pmc_article_factory'
RSpec.describe PMCArticle do
let(:pmc_article) do
build(:pmc_article)
end
it 'parses pmid' do
expect(pmc_article.article_id_pmid).to eq '123456'
end
end
但是当我运行bundle exec rspec
我得到
1) PMCArticle parses pmid
Failure/Error: build(:pmc_article)
NoMethodError:
undefined method `build' for #<RSpec::ExampleGroups::PMCArticle:0x007feac3cc5078>
# ./spec/pmc_article_spec.rb:8:in `block (2 levels) in <top (required)>'
# ./spec/pmc_article_spec.rb:12:in `block (2 levels) in <top (required)>'
我认为rspec的失败,要求spec/support/factory_girl.rb
,即使工厂女孩入门指南说我应该把文件存在。
我已经运行命令行命令初始化rspec的时候我开始这个项目,这是我使用的工厂女孩项目之前。
为什么不符合规格/支持RSpec的加载文件?