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本身已加载(使用puts测试),黄瓜使用环境/ test.rb运行。
我缺少什么?
答案 0 :(得分:0)
您的步骤def没有使用正确的措辞。
默认的Pickle步骤(您可以根据自己的应用/风格调整它们)需要以下内容:
鉴于存在标题类别:“有史以来第一类”
干杯, 伊恩