Skip to content

Instantly share code, notes, and snippets.

@antifuchs
Created May 2, 2010 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antifuchs/387363 to your computer and use it in GitHub Desktop.
Save antifuchs/387363 to your computer and use it in GitHub Desktop.
Scenario: Suggestions for undefined steps with and without arguments # features/snippet_texts.feature:6
Given a standard Cucumber project directory structure # features/step_definitions/cucumber_steps.rb:7
Given the standard clucumber setup # features/step_definitions/clucumber_steps.rb:33
Given a file named "features/undefined.feature" with: # features/step_definitions/cucumber_steps.rb:20
"""
Feature: Undefined steps
Scenario: Three undefined steps
Given this step is undefined
When I use a step with "one arg"
Then the step "with two args" should "suggest two args"
"""
When I run cucumber -f progress # features/step_definitions/cucumber_steps.rb:24
Then it should pass with # features/step_definitions/cucumber_steps.rb:38
"""
UUU
1 scenario (1 undefined)
3 steps (3 undefined)
You can implement step definitions for undefined steps with these snippets:
Given /^this step is undefined$/ do
pending # express the regexp above with the code you wish you had
end
(Given* #?{^this step is undefined$} ()
;; express the regexp above with the code you wish you had
(pending))
When /^I use a step with "([^"]*)"$/ do |arg1|
pending # express the regexp above with the code you wish you had
end
(When* #?{^I use a step with "([^"]*)"$} (group-0)
;; express the regexp above with the code you wish you had
(pending))
Then /^the step "([^"]*)" should "([^"]*)"$/ do |arg1, arg2|
pending # express the regexp above with the code you wish you had
end
(Then* #?{^the step "([^"]*)" should "([^"]*)"$} (group-0 group-1)
;; express the regexp above with the code you wish you had
(pending))
"""
expected: "UUU\n\n1 scenario (1 undefined)\n3 steps (3 undefined)\n\nYou can implement step definitions for undefined steps with these snippets:\n\nGiven /^this step is undefined$/ do\n pending # express the regexp above with the code you wish you had\nend\n(Given* #?{^this step is undefined$} ()\n ;; express the regexp above with the code you wish you had\n (pending))\n\nWhen /^I use a step with \"([^\"]*)\"$/ do |arg1|\n pending # express the regexp above with the code you wish you had\nend\n(When* #?{^I use a step with \"([^\"]*)\"$} (group-0)\n ;; express the regexp above with the code you wish you had\n (pending))\n\nThen /^the step \"([^\"]*)\" should \"([^\"]*)\"$/ do |arg1, arg2|\n pending # express the regexp above with the code you wish you had\nend\n(Then* #?{^the step \"([^\"]*)\" should \"([^\"]*)\"$} (group-0 group-1)\n ;; express the regexp above with the code you wish you had\n (pending))\n\n",
got: "UUU\n\n1 scenario (1 undefined)\n3 steps (3 undefined)\n\nYou can implement step definitions for undefined steps with these snippets:\n\nGiven /^this step is undefined$/ do\n pending # express the regexp above with the code you wish you had\nend\n(Given* #?{^this step is undefined$} ()\n ;; express the regexp above with the code you wish you had\n (pending))\n\nWhen /^I use a step with \"([^\\\"]*)\"$/ do |arg1|\n pending # express the regexp above with the code you wish you had\nend\n(When* #?{^I use a step with \"([^\"]*)\"$} (group-0)\n ;; express the regexp above with the code you wish you had\n (pending))\n\nThen /^the step \"([^\\\"]*)\" should \"([^\\\"]*)\"$/ do |arg1, arg2|\n pending # express the regexp above with the code you wish you had\nend\n(Then* #?{^the step \"([^\"]*)\" should \"([^\"]*)\"$} (group-0 group-1)\n ;; express the regexp above with the code you wish you had\n (pending))\n\n" (using ==)
Diff:
@@ -12,14 +12,14 @@
;; express the regexp above with the code you wish you had
(pending))
-When /^I use a step with "([^"]*)"$/ do |arg1|
+When /^I use a step with "([^\"]*)"$/ do |arg1|
pending # express the regexp above with the code you wish you had
end
(When* #?{^I use a step with "([^"]*)"$} (group-0)
;; express the regexp above with the code you wish you had
(pending))
-Then /^the step "([^"]*)" should "([^"]*)"$/ do |arg1, arg2|
+Then /^the step "([^\"]*)" should "([^\"]*)"$/ do |arg1, arg2|
pending # express the regexp above with the code you wish you had
end
(Then* #?{^the step "([^"]*)" should "([^"]*)"$} (group-0 group-1)
(Spec::Expectations::ExpectationNotMetError)
./features/step_definitions/cucumber_steps.rb:39:in `/^it should (fail|pass) with$/'
features/snippet_texts.feature:20:in `Then it should pass with'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment