发现测试中有很多这类代码,能请问下这是哪里定义的么?
let(:site_node) { Factory :site_node }
FactoryGirl ...
https://github.com/thoughtbot/factory_girl/blob/master/GETTING_STARTED.md 連結給你附上了...
我在自己的项目中也这么定义了,却出来
Failure/Error: let(:comment) { FactoryGirl.create(:comment)} Optionable::Unknown: :consistency is an unknown option. Valid options are: :write, :read, :database, :max_retries, :pool_size, :retry_interval, :refresh_interval, :down_interval, :ssl, :timeout, :instrumented.
我怀疑是 mongoid 和 rspec 的兼容问题。
SHIT, 是 mongoid 升级后把 consistency option 给去掉了。 https://github.com/mongoid/mongoid/blob/master/CHANGELOG.md
#2 楼 @bcmic @iBachue 哦。原来最新的 factory girl 语法变了。现在得用
let(:site_node) { FactoryGirl.create :site_node }