Skip to content
This repository
Browse code

Merge pull request #237 from meyering/master

suggestion for slightly cleaner regexps
  • Loading branch information...
commit cf1eeb7a97d3f589851b9c26d18cc9a121667717 2 parents 356ebed + af4625c
Matt Wynne mattwynne authored
2  lib/cucumber/js_support/js_snippets.rb
... ... @@ -1,7 +1,7 @@
1 1 module Cucumber
2 2 module JsSupport
3 3 module JsSnippets
4   - PARAM_PATTERN = /"([^"]*)"/
  4 + PARAM_PATTERN = /"(.*?)"/
5 5 ESCAPED_PARAM_PATTERN = '"([^\\"]*)"'
6 6
7 7 def snippet_text(code_keyword, step_name, multiline_arg_class)
2  lib/cucumber/rb_support/rb_language.rb
@@ -75,7 +75,7 @@ def step_matches(name_to_match, name_to_format)
75 75 end.compact
76 76 end
77 77
78   - ARGUMENT_PATTERNS = ['"([^"]*)"', '(\d+)']
  78 + ARGUMENT_PATTERNS = ['"(.*?)"', '(\d+)']
79 79
80 80 def snippet_text(code_keyword, step_name, multiline_arg_class)
81 81 snippet_pattern = Regexp.escape(step_name).gsub('\ ', ' ').gsub('/', '\/')
10 spec/cucumber/rb_support/rb_language_spec.rb
@@ -31,7 +31,7 @@ def unindented(s)
31 31
32 32 it "should recognise a mix of ints, strings and why not a table too" do
33 33 rb.snippet_text('Given', 'I have 9 "awesome" cukes in 37 "boxes"', Cucumber::Ast::Table).should == unindented(%{
34   - Given /^I have (\\d+) "([^"]*)" cukes in (\\d+) "([^"]*)"$/ do |arg1, arg2, arg3, arg4, table|
  34 + Given /^I have (\\d+) "(.*?)" cukes in (\\d+) "(.*?)"$/ do |arg1, arg2, arg3, arg4, table|
35 35 # table is a Cucumber::Ast::Table
36 36 pending # express the regexp above with the code you wish you had
37 37 end
@@ -40,7 +40,7 @@ def unindented(s)
40 40
41 41 it "should recognise quotes in name and make according regexp" do
42 42 rb.snippet_text('Given', 'A "first" arg', nil).should == unindented(%{
43   - Given /^A "([^"]*)" arg$/ do |arg1|
  43 + Given /^A "(.*?)" arg$/ do |arg1|
44 44 pending # express the regexp above with the code you wish you had
45 45 end
46 46 })
@@ -48,7 +48,7 @@ def unindented(s)
48 48
49 49 it "should recognise several quoted words in name and make according regexp and args" do
50 50 rb.snippet_text('Given', 'A "first" and "second" arg', nil).should == unindented(%{
51   - Given /^A "([^"]*)" and "([^"]*)" arg$/ do |arg1, arg2|
  51 + Given /^A "(.*?)" and "(.*?)" arg$/ do |arg1, arg2|
52 52 pending # express the regexp above with the code you wish you had
53 53 end
54 54 })
@@ -64,7 +64,7 @@ def unindented(s)
64 64
65 65 it "should be helpful with tables" do
66 66 rb.snippet_text('Given', 'A "first" arg', Cucumber::Ast::Table).should == unindented(%{
67   - Given /^A "([^"]*)" arg$/ do |arg1, table|
  67 + Given /^A "(.*?)" arg$/ do |arg1, table|
68 68 # table is a Cucumber::Ast::Table
69 69 pending # express the regexp above with the code you wish you had
70 70 end
@@ -279,4 +279,4 @@ class << rb.current_world
279 279
280 280 end
281 281 end
282   -end
  282 +end

0 comments on commit cf1eeb7

Please sign in to comment.
Something went wrong with that request. Please try again.