测试 ruby-china 的测试代码中用的 Factory 语法是哪里定义的?

hardywu · 2013年12月17日 · 最后由 hardywu 回复于 2013年12月18日 · 2654 次阅读

Update: It is merely that the new FactoryGirl is incompatible with the old syntax.

发现测试中有很多这类代码,能请问下这是哪里定义的么?

let(:site_node) { Factory :site_node }

FactoryGirl ...

我在自己的项目中也这么定义了,却出来

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 }
需要 登录 后方可回复, 如果你还没有账号请 注册新账号