使用 Factory Girl、Rspec2 和 Rails 3.1.0

发布于 2024-12-08 03:44:41 字数 1390 浏览 0 评论 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

偏闹i 2024-12-15 03:44:41

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. =)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文