未定义的泡菜步骤(再次)

发布于 2024-12-05 05:26:08 字数 1862 浏览 1 评论 0原文

https://stackoverflow.com/questions/5282437/cucumber- pickle-factory-girl-given-a-returning-undefined-step - 这篇文章对我没有多大帮助。

Gemfile:

gem 'rails' # 3.0.5
gem 'capybara' # 1.1.1
gem 'rspec-rails' # 2.6.1
gem 'cucumber-rails' # 1.0.5
gem 'database_cleaner'
gem 'factory_girl_rails' # 1.2.0
gem 'email_spec'
gem 'pickle' # 0.4.8

我做:

rails new pickle_test
bundle install
rails g cucumber:install
rails g rspec:install
rails g pickle --paths --email
rails g scaffold category title:string 
rake db:migrate
rake db:test:prepare
cucumber

我有:

$ cucumber
Using the default profile...
Feature: Manage categories

  Scenario: list existed categories                       # features/manage_categories.feature:3
    Given a category exists, title: "First category ever" # features/manage_categories.feature:4
      Undefined step: "a category exists, title: "First category ever"" (Cucumber::Undefined)
      features/manage_categories.feature:4:in `Given a category exists, title: "First category ever"'
    When I go to the categories page                      # features/step_definitions/web_steps.rb:48
    Then I should see "First category ever"               # features/step_definitions/web_steps.rb:105

1 scenario (1 undefined)
3 steps (2 skipped, 1 undefined)
0m0.127s

You can implement step definitions for undefined steps with these snippets:

Given /^a category exists, title: "([^"]*)"$/ do |arg1|
  pending # express the regexp above with the code you wish you had
end

请注意,我没有做任何事情来配置这个测试应用程序,而且我不使用factory_girl或任何东西而不是ActiveRecord。我相信它应该从那里开始工作。 Pickle 本身已加载(使用 put 进行测试),cucumber 使用environments/test.rb 运行。

我缺少什么?

https://stackoverflow.com/questions/5282437/cucumber-pickle-factory-girl-given-a-returning-undefined-step - this post didn't help me a lot.

Gemfile:

gem 'rails' # 3.0.5
gem 'capybara' # 1.1.1
gem 'rspec-rails' # 2.6.1
gem 'cucumber-rails' # 1.0.5
gem 'database_cleaner'
gem 'factory_girl_rails' # 1.2.0
gem 'email_spec'
gem 'pickle' # 0.4.8

I do:

rails new pickle_test
bundle install
rails g cucumber:install
rails g rspec:install
rails g pickle --paths --email
rails g scaffold category title:string 
rake db:migrate
rake db:test:prepare
cucumber

I have:

$ cucumber
Using the default profile...
Feature: Manage categories

  Scenario: list existed categories                       # features/manage_categories.feature:3
    Given a category exists, title: "First category ever" # features/manage_categories.feature:4
      Undefined step: "a category exists, title: "First category ever"" (Cucumber::Undefined)
      features/manage_categories.feature:4:in `Given a category exists, title: "First category ever"'
    When I go to the categories page                      # features/step_definitions/web_steps.rb:48
    Then I should see "First category ever"               # features/step_definitions/web_steps.rb:105

1 scenario (1 undefined)
3 steps (2 skipped, 1 undefined)
0m0.127s

You can implement step definitions for undefined steps with these snippets:

Given /^a category exists, title: "([^"]*)"$/ do |arg1|
  pending # express the regexp above with the code you wish you had
end

Note that I did nothing to configure this test app anyhow and I don't use factory_girl or anything rather then ActiveRecord. I'm confident it should work from there. Pickle itself is loaded (tested with puts), cucumber runs using environments/test.rb.

What I am missing?

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

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

发布评论

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

评论(1

童话里做英雄 2024-12-12 05:26:08

您的步骤 def 未使用正确的措辞。

默认的 Pickle 步骤(您应该随意调整它们以适应您的应用程序/风格)期望如下:

给定一个标题为“第一个类别”的类别,

干杯,
伊恩

Your step def is not using the correct phraseology.

The default Pickle steps (you should feel free to adapt them to your app/style) expect the following:

Given a category exists with title: "First category ever"

Cheers,
Ian

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