kosmas58-cucumber 0.3.96 → 0.3.97

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/History.txt +22 -3
  2. data/License.txt +2 -0
  3. data/Manifest.txt +9 -5
  4. data/config/hoe.rb +1 -0
  5. data/examples/i18n/Rakefile +5 -3
  6. data/examples/i18n/fi/features/yhteenlasku.feature +5 -4
  7. data/examples/python/features/step_definitions/fib_steps.py +3 -0
  8. data/examples/python/features/support/env.rb +21 -21
  9. data/gem_tasks/contributors.rake +8 -0
  10. data/gem_tasks/features.rake +1 -0
  11. data/gem_tasks/sdoc.rake +7 -0
  12. data/lib/README.rdoc +12 -0
  13. data/lib/cucumber/ast/background.rb +1 -1
  14. data/lib/cucumber/ast/comment.rb +1 -1
  15. data/lib/cucumber/ast/examples.rb +9 -4
  16. data/lib/cucumber/ast/feature.rb +1 -1
  17. data/lib/cucumber/ast/feature_element.rb +1 -1
  18. data/lib/cucumber/ast/features.rb +1 -1
  19. data/lib/cucumber/ast/outline_table.rb +2 -2
  20. data/lib/cucumber/ast/py_string.rb +1 -1
  21. data/lib/cucumber/ast/scenario.rb +1 -1
  22. data/lib/cucumber/ast/scenario_outline.rb +8 -7
  23. data/lib/cucumber/ast/step.rb +1 -1
  24. data/lib/cucumber/ast/step_collection.rb +1 -1
  25. data/lib/cucumber/ast/step_invocation.rb +1 -1
  26. data/lib/cucumber/ast/table.rb +65 -45
  27. data/lib/cucumber/ast/tags.rb +2 -2
  28. data/lib/cucumber/ast/visitor.rb +6 -8
  29. data/lib/cucumber/broadcaster.rb +1 -1
  30. data/lib/cucumber/cli/language_help_formatter.rb +1 -1
  31. data/lib/cucumber/cli/main.rb +15 -52
  32. data/lib/cucumber/constantize.rb +1 -1
  33. data/lib/cucumber/core_ext/exception.rb +1 -1
  34. data/lib/cucumber/core_ext/instance_exec.rb +8 -3
  35. data/lib/cucumber/core_ext/proc.rb +1 -1
  36. data/lib/cucumber/core_ext/string.rb +1 -1
  37. data/lib/cucumber/feature_file.rb +4 -3
  38. data/lib/cucumber/filter.rb +2 -1
  39. data/lib/cucumber/formatter/ansicolor.rb +6 -5
  40. data/lib/cucumber/formatter/color_io.rb +2 -2
  41. data/lib/cucumber/formatter/console.rb +2 -0
  42. data/lib/cucumber/formatter/duration.rb +3 -0
  43. data/lib/cucumber/formatter/html.rb +1 -0
  44. data/lib/cucumber/formatter/junit.rb +1 -0
  45. data/lib/cucumber/formatter/ordered_xml_markup.rb +1 -1
  46. data/lib/cucumber/formatter/pretty.rb +18 -4
  47. data/lib/cucumber/formatter/profile.rb +1 -0
  48. data/lib/cucumber/formatter/progress.rb +1 -0
  49. data/lib/cucumber/formatter/rerun.rb +2 -0
  50. data/lib/cucumber/formatter/steps.rb +1 -0
  51. data/lib/cucumber/formatter/tag_cloud.rb +2 -1
  52. data/lib/cucumber/formatter/unicode.rb +1 -1
  53. data/lib/cucumber/formatter/usage.rb +1 -0
  54. data/lib/cucumber/language_support/language_methods.rb +34 -12
  55. data/lib/cucumber/language_support.rb +30 -0
  56. data/lib/cucumber/parser/feature.rb +81 -57
  57. data/lib/cucumber/parser/feature.tt +3 -3
  58. data/lib/cucumber/parser/natural_language.rb +1 -1
  59. data/lib/cucumber/parser/table.rb +3 -0
  60. data/lib/cucumber/parser/treetop_ext.rb +6 -5
  61. data/lib/cucumber/platform.rb +1 -2
  62. data/lib/cucumber/py_support/py_dsl.py +8 -0
  63. data/lib/cucumber/py_support/py_language.py +2 -0
  64. data/lib/cucumber/py_support/py_language.rb +68 -0
  65. data/lib/cucumber/rails/world.rb +2 -1
  66. data/lib/cucumber/rake/task.rb +13 -11
  67. data/lib/cucumber/rb_support/rb_dsl.rb +27 -15
  68. data/lib/cucumber/rb_support/rb_hook.rb +1 -2
  69. data/lib/cucumber/rb_support/rb_language.rb +57 -33
  70. data/lib/cucumber/rb_support/rb_step_definition.rb +42 -38
  71. data/lib/cucumber/rb_support/rb_world.rb +93 -0
  72. data/lib/cucumber/rspec_neuter.rb +3 -3
  73. data/lib/cucumber/step_match.rb +2 -2
  74. data/lib/cucumber/step_mother.rb +91 -65
  75. data/lib/cucumber/version.rb +1 -1
  76. data/lib/cucumber/webrat/element_locator.rb +3 -3
  77. data/rails_generators/cucumber/templates/cucumber.rake +2 -0
  78. data/rails_generators/cucumber/templates/en/webrat_steps.rb +4 -0
  79. data/spec/cucumber/ast/background_spec.rb +8 -1
  80. data/spec/cucumber/ast/scenario_outline_spec.rb +1 -0
  81. data/spec/cucumber/ast/table_spec.rb +10 -0
  82. data/spec/cucumber/cli/options_spec.rb +1 -1
  83. data/spec/cucumber/parser/feature_parser_spec.rb +4 -0
  84. data/spec/cucumber/rb_support/rb_step_definition_spec.rb +114 -0
  85. data/spec/cucumber/step_mother_spec.rb +29 -10
  86. data/spec/cucumber/treetop_parser/with_comments.feature +14 -1
  87. data/spec/cucumber/world/pending_spec.rb +1 -1
  88. metadata +21 -7
  89. data/gem_tasks/yard.rake +0 -8
  90. data/lib/cucumber/language_support/hook_methods.rb +0 -9
  91. data/lib/cucumber/world.rb +0 -89
  92. data/spec/cucumber/ast/visitor_spec.rb +0 -27
  93. data/spec/cucumber/step_definition_spec.rb +0 -102
@@ -1,12 +1,12 @@
1
+ require 'logger'
1
2
  require 'cucumber/constantize'
2
- require 'cucumber/world'
3
3
  require 'cucumber/core_ext/instance_exec'
4
4
  require 'cucumber/parser/natural_language'
5
- require 'cucumber/language_support/hook_methods'
6
5
  require 'cucumber/language_support/language_methods'
7
6
  require 'cucumber/language_support/step_definition_methods'
8
7
 
9
8
  module Cucumber
9
+ # Raised when there is no matching StepDefinition for a step.
10
10
  class Undefined < StandardError
11
11
  attr_reader :step_name
12
12
 
@@ -28,7 +28,7 @@ module Cucumber
28
28
  class Pending < StandardError
29
29
  end
30
30
 
31
- # Raised when a step matches 2 or more StepDefinition
31
+ # Raised when a step matches 2 or more StepDefinitions
32
32
  class Ambiguous < StandardError
33
33
  def initialize(step_name, step_definitions, used_guess)
34
34
  message = "Ambiguous match of \"#{step_name}\":\n\n"
@@ -49,27 +49,61 @@ module Cucumber
49
49
  end
50
50
  end
51
51
 
52
- # This is the main interface for registering step definitions, which is done
53
- # from <tt>*_steps.rb</tt> files. This module is included right at the top-level
54
- # so #register_step_definition (and more interestingly - its aliases) are
55
- # available from the top-level.
52
+ # This is the meaty part of Cucumber that ties everything together.
56
53
  class StepMother
57
54
  include Constantize
58
55
 
59
- attr_writer :options, :visitor
56
+ attr_writer :options, :visitor, :log
60
57
 
61
58
  def initialize
59
+ @unsupported_programming_languages = []
62
60
  @programming_languages = []
63
61
  @language_map = {}
64
62
  load_natural_language('en')
65
63
  end
66
64
 
65
+ def load_plain_text_features(feature_files)
66
+ features = Ast::Features.new
67
+
68
+ log.debug("Features:\n")
69
+ feature_files.each do |f|
70
+ feature_file = FeatureFile.new(f)
71
+ feature = feature_file.parse(self, options)
72
+ if feature
73
+ features.add_feature(feature)
74
+ log.debug(" * #{f}\n")
75
+ end
76
+ end
77
+ log.debug("\n")
78
+ features
79
+ end
80
+
81
+ def load_code_files(step_def_files)
82
+ log.debug("Code:\n")
83
+ step_def_files.each do |step_def_file|
84
+ load_code_file(step_def_file)
85
+ end
86
+ log.debug("\n")
87
+ end
88
+
89
+ def load_code_file(step_def_file)
90
+ if programming_language = programming_language_for(step_def_file)
91
+ log.debug(" * #{step_def_file}\n")
92
+ step_definitions = programming_language.step_definitions_for(step_def_file)
93
+ register_step_definitions(step_definitions)
94
+ else
95
+ log.debug(" * #{step_def_file} [NOT SUPPORTED]\n")
96
+ end
97
+ end
98
+
99
+ def register_step_definitions(step_definitions)
100
+ step_definitions.each{|step_definition| register_step_definition(step_definition)}
101
+ end
102
+
67
103
  # Loads and registers programming language implementation.
68
104
  # Instances are cached, so calling with the same argument
69
105
  # twice will return the same instance.
70
106
  #
71
- # Raises an exception if the language can't be loaded.
72
- #
73
107
  def load_programming_language(ext)
74
108
  return @language_map[ext] if @language_map[ext]
75
109
  programming_language_class = constantize("Cucumber::#{ext.capitalize}Support::#{ext.capitalize}Language")
@@ -88,26 +122,16 @@ module Cucumber
88
122
  Parser::NaturalLanguage.get(self, lang)
89
123
  end
90
124
 
91
- # Registers a StepDefinition. This can be a Ruby StepDefintion,
92
- # or any other kind of object that implements the StepDefintion
93
- # contract (API).
94
- def register_step_definition(step_definition)
95
- step_definitions.each do |already|
96
- raise Redundant.new(already, step_definition) if already.same_regexp?(step_definition.regexp)
97
- end
98
- step_definitions << step_definition
99
- step_definition
100
- end
101
-
125
+ # Returns the options passed on the command line.
102
126
  def options
103
127
  @options ||= {}
104
128
  end
105
129
 
106
- def step_visited(step)
130
+ def step_visited(step) #:nodoc:
107
131
  steps << step unless steps.index(step)
108
132
  end
109
-
110
- def steps(status = nil)
133
+
134
+ def steps(status = nil) #:nodoc:
111
135
  @steps ||= []
112
136
  if(status)
113
137
  @steps.select{|step| step.status == status}
@@ -116,11 +140,11 @@ module Cucumber
116
140
  end
117
141
  end
118
142
 
119
- def announce(msg)
143
+ def announce(msg) #:nodoc:
120
144
  @visitor.announce(msg)
121
145
  end
122
146
 
123
- def scenarios(status = nil)
147
+ def scenarios(status = nil) #:nodoc:
124
148
  @scenarios ||= []
125
149
  if(status)
126
150
  @scenarios.select{|scenario| scenario.status == status}
@@ -129,20 +153,7 @@ module Cucumber
129
153
  end
130
154
  end
131
155
 
132
- def register_hook(phase, hook)
133
- hooks[phase.to_sym] << hook
134
- hook
135
- end
136
-
137
- def hooks
138
- @hooks ||= Hash.new {|hash, phase| hash[phase] = []}
139
- end
140
-
141
- def hooks_for(phase, scenario)
142
- hooks[phase.to_sym].select{|hook| scenario.accept_hook?(hook)}
143
- end
144
-
145
- def step_match(step_name, formatted_step_name=nil)
156
+ def step_match(step_name, formatted_step_name=nil) #:nodoc:
146
157
  matches = step_definitions.map { |d| d.step_match(step_name, formatted_step_name) }.compact
147
158
  raise Undefined.new(step_name) if matches.empty?
148
159
  matches = best_matches(step_name, matches) if matches.size > 1 && options[:guess]
@@ -150,7 +161,7 @@ module Cucumber
150
161
  matches[0]
151
162
  end
152
163
 
153
- def best_matches(step_name, step_matches)
164
+ def best_matches(step_name, step_matches) #:nodoc:
154
165
  no_groups = step_matches.select {|step_match| step_match.args.length == 0}
155
166
  max_arg_length = step_matches.map {|step_match| step_match.args.length }.max
156
167
  top_groups = step_matches.select {|step_match| step_match.args.length == max_arg_length }
@@ -166,31 +177,31 @@ module Cucumber
166
177
  end
167
178
  end
168
179
 
169
- def clear!
180
+ def clear! #:nodoc:
170
181
  step_definitions.clear
171
182
  hooks.clear
172
183
  steps.clear
173
184
  scenarios.clear
174
185
  end
175
186
 
176
- def step_definitions
187
+ def step_definitions #:nodoc:
177
188
  @step_definitions ||= []
178
189
  end
179
190
 
180
- def snippet_text(step_keyword, step_name, multiline_arg_class)
191
+ def snippet_text(step_keyword, step_name, multiline_arg_class) #:nodoc:
181
192
  @programming_languages.map do |programming_language|
182
193
  programming_language.snippet_text(step_keyword, step_name, multiline_arg_class)
183
194
  end.join("\n")
184
195
  end
185
196
 
186
- def before_and_after(scenario, skip_hooks=false)
197
+ def before_and_after(scenario, skip_hooks=false) #:nodoc:
187
198
  before(scenario) unless skip_hooks
188
199
  yield scenario
189
200
  after(scenario) unless skip_hooks
190
201
  scenario_visited(scenario)
191
202
  end
192
203
 
193
- def register_adverbs(adverbs)
204
+ def register_adverbs(adverbs) #:nodoc:
194
205
  @adverbs ||= []
195
206
  @adverbs += adverbs
196
207
  @adverbs.uniq!
@@ -198,22 +209,8 @@ module Cucumber
198
209
  programming_language.alias_adverbs(@adverbs)
199
210
  end
200
211
  end
201
-
202
- def begin_scenario
203
- return if options[:dry_run]
204
- @programming_languages.each do |programming_language|
205
- programming_language.begin_scenario
206
- end
207
- end
208
-
209
- def end_scenario
210
- return if options[:dry_run]
211
- @programming_languages.each do |programming_language|
212
- programming_language.end_scenario
213
- end
214
- end
215
212
 
216
- def before(scenario)
213
+ def before(scenario) #:nodoc:
217
214
  return if options[:dry_run] || @current_scenario
218
215
  @current_scenario = scenario
219
216
  @programming_languages.each do |programming_language|
@@ -221,7 +218,7 @@ module Cucumber
221
218
  end
222
219
  end
223
220
 
224
- def after(scenario)
221
+ def after(scenario) #:nodoc:
225
222
  @current_scenario = nil
226
223
  return if options[:dry_run]
227
224
  @programming_languages.each do |programming_language|
@@ -229,7 +226,7 @@ module Cucumber
229
226
  end
230
227
  end
231
228
 
232
- def after_step
229
+ def after_step #:nodoc:
233
230
  return if options[:dry_run]
234
231
  @programming_languages.each do |programming_language|
235
232
  programming_language.execute_after_step(@current_scenario)
@@ -238,12 +235,41 @@ module Cucumber
238
235
 
239
236
  private
240
237
 
241
- def max_step_definition_length
238
+ # Registers a StepDefinition. This can be a Ruby StepDefintion,
239
+ # or any other kind of object that implements the StepDefintion
240
+ # contract (API).
241
+ def register_step_definition(step_definition)
242
+ step_definitions.each do |already|
243
+ raise Redundant.new(already, step_definition) if already.same_regexp?(step_definition.regexp)
244
+ end
245
+ step_definitions << step_definition
246
+ step_definition
247
+ end
248
+
249
+ def programming_language_for(step_def_file) #:nodoc:
250
+ if ext = File.extname(step_def_file)[1..-1]
251
+ return nil if @unsupported_programming_languages.index(ext)
252
+ begin
253
+ load_programming_language(ext)
254
+ rescue LoadError
255
+ @unsupported_programming_languages << ext
256
+ nil
257
+ end
258
+ else
259
+ nil
260
+ end
261
+ end
262
+
263
+ def max_step_definition_length #:nodoc:
242
264
  @max_step_definition_length ||= step_definitions.map{|step_definition| step_definition.text_length}.max
243
265
  end
244
266
 
245
- def scenario_visited(scenario)
267
+ def scenario_visited(scenario) #:nodoc:
246
268
  scenarios << scenario unless scenarios.index(scenario)
247
269
  end
270
+
271
+ def log
272
+ @log ||= Logger.new(STDOUT)
273
+ end
248
274
  end
249
275
  end
@@ -2,7 +2,7 @@ module Cucumber #:nodoc:
2
2
  class VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- TINY = 96
5
+ TINY = 97
6
6
  PATCH = nil # Set to nil for official release
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PATCH].compact.join('.')
@@ -55,7 +55,7 @@ module Webrat
55
55
  end
56
56
 
57
57
  module Locators
58
- class ElementLocator < Locator
58
+ class ElementLocator < Locator #:nodoc:
59
59
  def locate
60
60
  Element.load(@session, table_element)
61
61
  end
@@ -77,11 +77,11 @@ module Webrat
77
77
  alias table_at element_at # Backwards compatibility with Cucumber
78
78
  end
79
79
 
80
- module Methods
80
+ module Methods #:nodoc:
81
81
  delegate_to_session :element_at, :table_at
82
82
  end
83
83
 
84
- class Session
84
+ class Session #:nodoc:
85
85
  def_delegators :current_scope, :element_at, :table_at
86
86
  end
87
87
  end
@@ -25,6 +25,8 @@ begin
25
25
  desc 'Alias for cucumber:ok'
26
26
  task :cucumber => 'cucumber:ok'
27
27
 
28
+ task :default => :cucumber
29
+
28
30
  task :features => :cucumber do
29
31
  STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
30
32
 
@@ -27,6 +27,10 @@ When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
27
27
  fill_in(field, :with => value)
28
28
  end
29
29
 
30
+ When /^I fill in "([^\"]*)" for "([^\"]*)"$/ do |value, field|
31
+ fill_in(field, :with => value)
32
+ end
33
+
30
34
  # Use this to fill in an entire form with data from a table. Example:
31
35
  #
32
36
  # When I fill in the following:
@@ -10,7 +10,7 @@ module Cucumber
10
10
  extend(RbSupport::RbDsl)
11
11
  @step_mother = StepMother.new
12
12
  @step_mother.load_natural_language('en')
13
- @step_mother.load_programming_language('rb')
13
+ @rb = @step_mother.load_programming_language('rb')
14
14
 
15
15
  $x = $y = nil
16
16
  Before do
@@ -19,12 +19,19 @@ module Cucumber
19
19
  Given /y is (\d+)/ do |n|
20
20
  $y = $x * n.to_i
21
21
  end
22
+
23
+ register
24
+
22
25
  @visitor = Visitor.new(@step_mother)
23
26
  @visitor.options = {}
24
27
 
25
28
  @feature = mock('feature', :visit? => true).as_null_object
26
29
  end
27
30
 
31
+ def register
32
+ @step_mother.register_step_definitions(@rb.step_definitions)
33
+ end
34
+
28
35
  it "should execute Before blocks before background steps" do
29
36
  background = Background.new(
30
37
  comment=Comment.new(''),
@@ -41,6 +41,7 @@ module Cucumber
41
41
  ],
42
42
  [
43
43
  [
44
+ Comment.new("#Mmmm... cucumbers\n"),
44
45
  24,
45
46
  'Examples:',
46
47
  'First table',
@@ -285,6 +285,16 @@ module Cucumber
285
285
  | aslak | true |
286
286
  }
287
287
  end
288
+
289
+ it "should not allow mappings that match more than 1 column" do
290
+ t1 = Table.new([
291
+ ['Cuke', 'Duke'],
292
+ ['Foo', 'Bar']
293
+ ])
294
+ lambda do
295
+ t1.map_headers!(/uk/ => 'u')
296
+ end.should raise_error(%{2 headers matched /uk/: ["Cuke", "Duke"]})
297
+ end
288
298
 
289
299
  describe "raising" do
290
300
  before do
@@ -46,7 +46,7 @@ module Cli
46
46
 
47
47
  context '-r or --require' do
48
48
  it "collects all specified files into an array" do
49
- after_parsing ('--require some_file.rb -r another_file.rb') do
49
+ after_parsing('--require some_file.rb -r another_file.rb') do
50
50
  options[:require].should == ['some_file.rb', 'another_file.rb']
51
51
  end
52
52
  end
@@ -349,6 +349,10 @@ Given I am a step
349
349
  it "should parse scenario_outline" do
350
350
  parse_file("scenario_outline.feature")
351
351
  end
352
+
353
+ it "should parse comments" do
354
+ parse_file("with_comments.feature")
355
+ end
352
356
  end
353
357
 
354
358
  describe "Filtering" do
@@ -0,0 +1,114 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ require 'cucumber/ast'
4
+ require 'cucumber/step_mother'
5
+ require 'cucumber/rb_support/rb_language'
6
+
7
+ module Cucumber
8
+ module RbSupport
9
+ describe RbStepDefinition do
10
+ before do
11
+ @step_mother = StepMother.new
12
+ @step_mother.load_natural_language('en')
13
+ @rb = @step_mother.load_programming_language('rb')
14
+ @dsl = Object.new
15
+ @dsl.extend RbSupport::RbDsl
16
+ @step_mother.before(nil)
17
+
18
+ $inside = nil
19
+ end
20
+
21
+ def register
22
+ @step_mother.register_step_definitions(@rb.step_definitions)
23
+ end
24
+
25
+ it "should allow calling of other steps" do
26
+ @dsl.Given /Outside/ do
27
+ Given "Inside"
28
+ end
29
+ @dsl.Given /Inside/ do
30
+ $inside = true
31
+ end
32
+ register
33
+
34
+ @step_mother.step_match("Outside").invoke(nil)
35
+ $inside.should == true
36
+ end
37
+
38
+ it "should allow calling of other steps with inline arg" do
39
+ @dsl.Given /Outside/ do
40
+ Given "Inside", Ast::Table.new([['inside']])
41
+ end
42
+ @dsl.Given /Inside/ do |table|
43
+ $inside = table.raw[0][0]
44
+ end
45
+ register
46
+
47
+ @step_mother.step_match("Outside").invoke(nil)
48
+ $inside.should == 'inside'
49
+ end
50
+
51
+ it "should raise Undefined when inside step is not defined" do
52
+ @dsl.Given /Outside/ do
53
+ Given 'Inside'
54
+ end
55
+ register
56
+
57
+ lambda do
58
+ @step_mother.step_match('Outside').invoke(nil)
59
+ end.should raise_error(Undefined, 'Undefined step: "Inside"')
60
+ end
61
+
62
+ it "should allow forced pending" do
63
+ @dsl.Given /Outside/ do
64
+ pending("Do me!")
65
+ end
66
+ register
67
+
68
+ lambda do
69
+ @step_mother.step_match("Outside").invoke(nil)
70
+ end.should raise_error(Pending, "Do me!")
71
+ end
72
+
73
+ it "should allow announce" do
74
+ v = mock('visitor')
75
+ v.should_receive(:announce).with('wasup')
76
+ @step_mother.visitor = v
77
+ @dsl.Given /Loud/ do
78
+ announce 'wasup'
79
+ end
80
+ register
81
+
82
+ @step_mother.step_match("Loud").invoke(nil)
83
+ end
84
+
85
+ def unindented(s)
86
+ s.split("\n")[1..-2].join("\n").indent(-10)
87
+ end
88
+
89
+ it "should recognise quotes in name and make according regexp" do
90
+ @rb.snippet_text('Given', 'A "first" arg').should == unindented(%{
91
+ Given /^A "([^\\"]*)" arg$/ do |arg1|
92
+ pending
93
+ end
94
+ })
95
+ end
96
+
97
+ it "should recognise several quoted words in name and make according regexp and args" do
98
+ @rb.snippet_text('Given', 'A "first" and "second" arg').should == unindented(%{
99
+ Given /^A "([^\\"]*)" and "([^\\"]*)" arg$/ do |arg1, arg2|
100
+ pending
101
+ end
102
+ })
103
+ end
104
+
105
+ it "should not use quote group when there are no quotes" do
106
+ @rb.snippet_text('Given', 'A first arg').should == unindented(%{
107
+ Given /^A first arg$/ do
108
+ pending
109
+ end
110
+ })
111
+ end
112
+ end
113
+ end
114
+ end
@@ -16,11 +16,17 @@ module Cucumber
16
16
  @visitor = mock('Visitor')
17
17
  end
18
18
 
19
+ def register
20
+ @step_mother.register_step_definitions(@rb.step_definitions)
21
+ end
22
+
19
23
  it "should format step names" do
20
24
  @dsl.Given(/it (.*) in (.*)/) do |what, month|
21
25
  end
22
26
  @dsl.Given(/nope something else/) do |what, month|
23
27
  end
28
+ register
29
+
24
30
  format = @step_mother.step_match("it snows in april").format_args("[%s]")
25
31
  format.should == "it [snows] in [april]"
26
32
  end
@@ -28,13 +34,14 @@ module Cucumber
28
34
  it "should raise Ambiguous error with guess hint when multiple step definitions match" do
29
35
  @dsl.Given(/Three (.*) mice/) {|disability|}
30
36
  @dsl.Given(/Three blind (.*)/) {|animal|}
37
+ register
31
38
 
32
39
  lambda do
33
40
  @step_mother.step_match("Three blind mice")
34
41
  end.should raise_error(Ambiguous, %{Ambiguous match of "Three blind mice":
35
42
 
36
- spec/cucumber/step_mother_spec.rb:29:in `/Three (.*) mice/'
37
- spec/cucumber/step_mother_spec.rb:30:in `/Three blind (.*)/'
43
+ spec/cucumber/step_mother_spec.rb:35:in `/Three (.*) mice/'
44
+ spec/cucumber/step_mother_spec.rb:36:in `/Three blind (.*)/'
38
45
 
39
46
  You can run again with --guess to make Cucumber be more smart about it
40
47
  })
@@ -42,15 +49,17 @@ You can run again with --guess to make Cucumber be more smart about it
42
49
 
43
50
  it "should not show --guess hint when --guess is used" do
44
51
  @step_mother.options = {:guess => true}
52
+
45
53
  @dsl.Given(/Three (.*) mice/) {|disability|}
46
54
  @dsl.Given(/Three cute (.*)/) {|animal|}
55
+ register
47
56
 
48
57
  lambda do
49
58
  @step_mother.step_match("Three cute mice")
50
59
  end.should raise_error(Ambiguous, %{Ambiguous match of "Three cute mice":
51
60
 
52
- spec/cucumber/step_mother_spec.rb:45:in `/Three (.*) mice/'
53
- spec/cucumber/step_mother_spec.rb:46:in `/Three cute (.*)/'
61
+ spec/cucumber/step_mother_spec.rb:53:in `/Three (.*) mice/'
62
+ spec/cucumber/step_mother_spec.rb:54:in `/Three cute (.*)/'
54
63
 
55
64
  })
56
65
  end
@@ -59,6 +68,7 @@ spec/cucumber/step_mother_spec.rb:46:in `/Three cute (.*)/'
59
68
  @step_mother.options = {:guess => true}
60
69
  @dsl.Given(/Three (.*) mice/) {|disability|}
61
70
  @dsl.Given(/Three (.*)/) {|animal|}
71
+ register
62
72
 
63
73
  lambda do
64
74
  @step_mother.step_match("Three blind mice")
@@ -69,6 +79,8 @@ spec/cucumber/step_mother_spec.rb:46:in `/Three cute (.*)/'
69
79
  @step_mother.options = {:guess => true}
70
80
  right = @dsl.Given(/Three (.*) mice/) {|disability|}
71
81
  wrong = @dsl.Given(/Three (.*)/) {|animal|}
82
+ register
83
+
72
84
  @step_mother.step_match("Three blind mice").step_definition.should == right
73
85
  end
74
86
 
@@ -76,6 +88,8 @@ spec/cucumber/step_mother_spec.rb:46:in `/Three cute (.*)/'
76
88
  @step_mother.options = {:guess => true}
77
89
  right = @dsl.Given(/Three (.*) mice ran (.*)/) {|disability|}
78
90
  wrong = @dsl.Given(/Three (.*)/) {|animal|}
91
+ register
92
+
79
93
  @step_mother.step_match("Three blind mice ran far").step_definition.should == right
80
94
  end
81
95
 
@@ -84,6 +98,8 @@ spec/cucumber/step_mother_spec.rb:46:in `/Three cute (.*)/'
84
98
  general = @dsl.Given(/Three (.*) mice ran (.*)/) {|disability|}
85
99
  specific = @dsl.Given(/Three blind mice ran far/) {}
86
100
  more_specific = @dsl.Given(/^Three blind mice ran far$/) {}
101
+ register
102
+
87
103
  @step_mother.step_match("Three blind mice ran far").step_definition.should == more_specific
88
104
  end
89
105
 
@@ -97,6 +113,7 @@ spec/cucumber/step_mother_spec.rb:46:in `/Three cute (.*)/'
97
113
  @dsl.Given(/Three (.*) mice/) {|disability|}
98
114
  lambda do
99
115
  @dsl.Given(/Three (.*) mice/) {|disability|}
116
+ register
100
117
  end.should raise_error(Redundant)
101
118
  end
102
119
 
@@ -104,6 +121,7 @@ spec/cucumber/step_mother_spec.rb:46:in `/Three cute (.*)/'
104
121
  it "should not raise Redundant unless it's really redundant" do
105
122
  @dsl.Given(/^(.*) (.*) user named '(.*)'$/) {|a,b,c|}
106
123
  @dsl.Given(/^there is no (.*) user named '(.*)'$/) {|a,b|}
124
+ register
107
125
  end
108
126
 
109
127
  it "should raise an error if the world is nil" do
@@ -115,7 +133,7 @@ spec/cucumber/step_mother_spec.rb:46:in `/Three cute (.*)/'
115
133
  raise "Should fail"
116
134
  rescue RbSupport::NilWorld => e
117
135
  e.message.should == "World procs should never return nil"
118
- e.backtrace.should == ["spec/cucumber/step_mother_spec.rb:110:in `World'"]
136
+ e.backtrace.should == ["spec/cucumber/step_mother_spec.rb:128:in `World'"]
119
137
  end
120
138
  end
121
139
 
@@ -130,7 +148,7 @@ spec/cucumber/step_mother_spec.rb:46:in `/Three cute (.*)/'
130
148
 
131
149
  it "should implicitly extend world with modules" do
132
150
  @dsl.World(ModuleOne, ModuleTwo)
133
- @step_mother.begin_scenario
151
+ @step_mother.before(nil)
134
152
  class << @rb.current_world
135
153
  included_modules.index(ModuleOne).should_not == nil
136
154
  included_modules.index(ModuleTwo).should_not == nil
@@ -145,10 +163,10 @@ spec/cucumber/step_mother_spec.rb:46:in `/Three cute (.*)/'
145
163
  end.should raise_error(RbSupport::MultipleWorld, %{You can only pass a proc to #World once, but it's happening
146
164
  in 2 places:
147
165
 
148
- spec/cucumber/step_mother_spec.rb:142:in `World'
149
- spec/cucumber/step_mother_spec.rb:144:in `World'
166
+ spec/cucumber/step_mother_spec.rb:160:in `World'
167
+ spec/cucumber/step_mother_spec.rb:162:in `World'
150
168
 
151
- Use Ruby modules instead to extend your worlds. See the Cucumber::StepMother#World RDoc
169
+ Use Ruby modules instead to extend your worlds. See the Cucumber::RbSupport::RbDsl#World RDoc
152
170
  or http://wiki.github.com/aslakhellesoy/cucumber/a-whole-new-world.
153
171
 
154
172
  })
@@ -157,12 +175,13 @@ or http://wiki.github.com/aslakhellesoy/cucumber/a-whole-new-world.
157
175
  it "should find before hooks" do
158
176
  fish = @dsl.Before('@fish'){}
159
177
  meat = @dsl.Before('@meat'){}
178
+ register
160
179
 
161
180
  scenario = mock('Scenario')
162
181
  scenario.should_receive(:accept_hook?).with(fish).and_return(true)
163
182
  scenario.should_receive(:accept_hook?).with(meat).and_return(false)
164
183
 
165
- @step_mother.hooks_for(:before, scenario).should == [fish]
184
+ @rb.hooks_for(:before, scenario).should == [fish]
166
185
  end
167
186
  end
168
187
  end