使用 Factory Girl、Rspec2 和 Rails 3.1.0
目前我正在尝试将 Factory Girl 集成到我的测试框架中。我成功地将 Factory Girl 与我的 Rails 3.1.0 应用程序集成,并且工作正常。
我正在使用
- rspec2
- Factory Girl
- Rails 3.1.0
以下是我的参考资料
http://www.pmamediagroup.com/2009/04/tutorial-install-rspec-rails-factory-girl/
https://github.com/thoughtbot/factory_girl/wiki
http://rdoc.info/github/thoughtbot/factory_girl/master
http://www.deploymentzone.com/2011 /05/19/factory_girl-rspec-2-and-rails-3/
http://www.codethinked.com/rails-3-baby-steps-第 3 部分
我可以编写一些测试用例,例如
it "user should valid with name" do
user = Factory.build(:with_name)
user.should be_valid
end
,正如我所看到的,有像 'should be_valid'
这样的命令,我的问题是,是否有任何地方可以获取所有命令在一个地方,所以我可以看到我可以使用哪些命令,例如 should be_valid
。
我已经浏览了 Factorygirl 文档,但找不到任何类似的地方。
Currently I'm trying to integrate factory girl for my testing framework. I was successfully able to integrate factory girl with my rails 3.1.0 app and its working fine.
I'm using
- rspec2
- factory girl
- rails 3.1.0
Following are the references I had
http://www.pmamediagroup.com/2009/04/tutorial-install-rspec-rails-factory-girl/
https://github.com/thoughtbot/factory_girl/wiki
http://rdoc.info/github/thoughtbot/factory_girl/master
http://www.deploymentzone.com/2011/05/19/factory_girl-rspec-2-and-rails-3/
http://www.codethinked.com/rails-3-baby-steps-part-3
And i could write some test cases like
it "user should valid with name" do
user = Factory.build(:with_name)
user.should be_valid
end
So as I can see there are commands like 'should be_valid'
, My question is , is there any place I can get all the commands in one place, so that I can see what are the commands I can use, like should be_valid
.
I have gone through the factorygirl documentation, but couldn't find any place like that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
https://www.relishapp.com/rspec
https://www.relishapp.com/rspec/rspec-expectations
.should 风格的比较糖是 rspec-expectations gem 的一部分。
请注意,您也可以编写自定义期望匹配器。 =)
https://www.relishapp.com/rspec
https://www.relishapp.com/rspec/rspec-expectations
That .should-style comparison sugar is part of the rspec-expectations gem.
Notice you can write custom expectation matchers as well. =)