在黄瓜中使用factory_girl构建工厂的更好方法

发布于 2024-09-18 23:00:26 字数 425 浏览 2 评论 0原文

我在 Rails 2.3.9 项目中使用 Cucumber 和 Factory_girl 。

这是我的一篇文章中的给定内容之一。

Given a user with first_name "Mary" and last_name "Jane"

我开始构建正则表达式,我可以在其中捕获以下项目。

model = user 
first_name = "Mary"
last_name = "Jane"
Factory(:user, :first_name => 'Mary', :last_name => "Jane")

鉴于 Cucumber 和 Factory_girl 如此受欢迎,我确信一定有更好的方法,而不是我重新发明轮子。

有什么好的解决办法呢?

I am using cucumber and factory_girl in a rails 2.3.9 project.

Here is one of the givens in one of my features.

Given a user with first_name "Mary" and last_name "Jane"

I started building the regex where I could capture following items.

model = user 
first_name = "Mary"
last_name = "Jane"
Factory(:user, :first_name => 'Mary', :last_name => "Jane")

Given how popular cucumber and factory_girl are, I'm sure there must be a better way rather than me reinventing the wheel.

What's a good solution?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文