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,11 +1,23 @@
1
1
  module Cucumber
2
2
  module Ast
3
- # Holds the data of a table parsed from a feature file:
3
+ # Step Definitions that match a plain text Step with a multiline argument table
4
+ # will receive it as an instance of Table. A Table object holds the data of a
5
+ # table parsed from a feature file and lets you access and manipulate the data
6
+ # in different ways.
4
7
  #
5
- # | a | b |
6
- # | c | d |
8
+ # For example:
7
9
  #
8
- # This gets parsed into a Table holding the values <tt>[['a', 'b'], ['c', 'd']]</tt>
10
+ # Given I have:
11
+ # | a | b |
12
+ # | c | d |
13
+ #
14
+ # And a matching StepDefinition:
15
+ #
16
+ # Given /I have:/ do |table|
17
+ # data = table.raw
18
+ # end
19
+ #
20
+ # This will store <tt>[['a', 'b'], ['c', 'd']]</tt> in the <tt>data</tt> variable.
9
21
  #
10
22
  class Table
11
23
  include Enumerable
@@ -14,10 +26,14 @@ module Cucumber
14
26
 
15
27
  attr_accessor :file
16
28
 
17
- def self.default_arg_name
29
+ def self.default_arg_name #:nodoc:
18
30
  "table"
19
31
  end
20
32
 
33
+ # Creates a new instance. +raw+ should be an Array of Array of String.
34
+ # You don't typically create your own Table objects - Cucumber will do
35
+ # it internally and pass them to your Step Definitions.
36
+ #
21
37
  def initialize(raw, conversion_procs = NULL_CONVERSIONS.dup)
22
38
  @cells_class = Cells
23
39
  @cell_class = Cell
@@ -28,21 +44,23 @@ module Cucumber
28
44
  @conversion_procs = conversion_procs
29
45
  end
30
46
 
31
- # Creates a copy of this table, inheriting the column mappings.
47
+ # Creates a copy of this table, inheriting any column mappings.
48
+ # registered with #map_headers!
49
+ #
32
50
  def dup
33
51
  self.class.new(raw.dup, @conversion_procs.dup)
34
52
  end
35
53
 
36
54
  # Returns a new, transposed table. Example:
37
55
  #
38
- # | a | 7 | 4 |
39
- # | b | 9 | 2 |
56
+ # | a | 7 | 4 |
57
+ # | b | 9 | 2 |
40
58
  #
41
59
  # Gets converted into the following:
42
60
  #
43
- # | a | b |
44
- # | 7 | 9 |
45
- # | 4 | 2 |
61
+ # | a | b |
62
+ # | 7 | 9 |
63
+ # | 4 | 2 |
46
64
  #
47
65
  def transpose
48
66
  self.class.new(raw.transpose, @conversion_procs.dup)
@@ -109,11 +127,11 @@ module Cucumber
109
127
  raw[1..-1]
110
128
  end
111
129
 
112
- def each_cells_row(&proc)
130
+ def each_cells_row(&proc) #:nodoc:
113
131
  cells_rows.each(&proc)
114
132
  end
115
133
 
116
- def accept(visitor)
134
+ def accept(visitor) #:nodoc:
117
135
  return if $cucumber_interrupted
118
136
  cells_rows.each do |row|
119
137
  visitor.visit_table_row(row)
@@ -149,8 +167,10 @@ module Cucumber
149
167
  def map_headers!(mappings)
150
168
  header_cells = cell_matrix[0]
151
169
  mappings.each_pair do |pre, post|
152
- header_cell = header_cells.detect{|cell| pre === cell.value}
153
- header_cell.value = post
170
+ mapped_cells = header_cells.select{|cell| pre === cell.value}
171
+ raise "No headers matched #{pre.inspect}" if mapped_cells.empty?
172
+ raise "#{mapped_cells.length} headers matched #{pre.inspect}: #{mapped_cells.map{|c| c.value}.inspect}" if mapped_cells.length > 1
173
+ mapped_cells[0].value = post
154
174
  if @conversion_procs.has_key?(pre)
155
175
  @conversion_procs[post] = @conversion_procs.delete(pre)
156
176
  end
@@ -204,10 +224,10 @@ module Cucumber
204
224
  # Whether to raise or not raise can be changed by setting values in
205
225
  # +options+ to true or false:
206
226
  #
207
- # * <tt>missing_row</tt>: Raise on missing rows (defaults to true)
208
- # * <tt>surplus_row</tt>: Raise on surplus rows (defaults to true)
209
- # * <tt>missing_col</tt>: Raise on missing columns (defaults to true)
210
- # * <tt>surplus_col</tt>: Raise on surplus columns (defaults to false)
227
+ # * <tt>missing_row</tt> : Raise on missing rows (defaults to true)
228
+ # * <tt>surplus_row</tt> : Raise on surplus rows (defaults to true)
229
+ # * <tt>missing_col</tt> : Raise on missing columns (defaults to true)
230
+ # * <tt>surplus_col</tt> : Raise on surplus columns (defaults to false)
211
231
  #
212
232
  # The +other_table+ argument can be another Table, an Array of Array or
213
233
  # an Array of Hash (similar to the structure returned by #hashes).
@@ -296,11 +316,11 @@ module Cucumber
296
316
  cells_rows.index(cells)
297
317
  end
298
318
 
299
- def verify_column(column_name)
319
+ def verify_column(column_name) #:nodoc:
300
320
  raise %{The column named "#{column_name}" does not exist} unless raw[0].include?(column_name)
301
321
  end
302
322
 
303
- def verify_table_width(width)
323
+ def verify_table_width(width) #:nodoc:
304
324
  raise %{The table must have exactly #{width} columns} unless raw[0].size == width
305
325
  end
306
326
 
@@ -319,33 +339,33 @@ module Cucumber
319
339
  Table.new(raw_with_replaced_args)
320
340
  end
321
341
 
322
- def has_text?(text)
342
+ def has_text?(text) #:nodoc:
323
343
  raw.flatten.compact.detect{|cell_value| cell_value.index(text)}
324
344
  end
325
345
 
326
- def cells_rows
346
+ def cells_rows #:nodoc:
327
347
  @rows ||= cell_matrix.map do |cell_row|
328
348
  @cells_class.new(self, cell_row)
329
349
  end
330
350
  end
331
351
 
332
- def headers
352
+ def headers #:nodoc:
333
353
  raw.first
334
354
  end
335
355
 
336
- def header_cell(col)
356
+ def header_cell(col) #:nodoc:
337
357
  cells_rows[0][col]
338
358
  end
339
359
 
340
- def cell_matrix
360
+ def cell_matrix #:nodoc:
341
361
  @cell_matrix
342
362
  end
343
363
 
344
- def col_width(col)
364
+ def col_width(col) #:nodoc:
345
365
  columns[col].__send__(:width)
346
366
  end
347
367
 
348
- def to_s(options = {})
368
+ def to_s(options = {}) #:nodoc:
349
369
  options = {:color => true, :indent => 2, :prefixes => TO_S_PREFIXES}.merge(options)
350
370
  io = StringIO.new
351
371
 
@@ -369,7 +389,7 @@ module Cucumber
369
389
 
370
390
  protected
371
391
 
372
- def inspect_rows(missing_row, inserted_row)
392
+ def inspect_rows(missing_row, inserted_row) #:nodoc:
373
393
  missing_row.each_with_index do |missing_cell, col|
374
394
  inserted_cell = inserted_row[col]
375
395
  if(missing_cell.value != inserted_cell.value && (missing_cell.value.to_s == inserted_cell.value.to_s))
@@ -379,7 +399,7 @@ module Cucumber
379
399
  end
380
400
  end
381
401
 
382
- def create_cell_matrix(raw)
402
+ def create_cell_matrix(raw) #:nodoc:
383
403
  @cell_matrix = raw.map do |raw_row|
384
404
  line = raw_row.line rescue -1
385
405
  raw_row.map do |raw_cell|
@@ -388,7 +408,7 @@ module Cucumber
388
408
  end
389
409
  end
390
410
 
391
- def convert_columns!
411
+ def convert_columns! #:nodoc:
392
412
  cell_matrix.transpose.each do |col|
393
413
  conversion_proc = @conversion_procs[col[0].value]
394
414
  col[1..-1].each do |cell|
@@ -397,7 +417,7 @@ module Cucumber
397
417
  end
398
418
  end
399
419
 
400
- def require_diff_lcs
420
+ def require_diff_lcs #:nodoc:
401
421
  begin
402
422
  require 'diff/lcs'
403
423
  rescue LoadError => e
@@ -406,23 +426,23 @@ module Cucumber
406
426
  end
407
427
  end
408
428
 
409
- def clear_cache!
429
+ def clear_cache! #:nodoc:
410
430
  @hashes = @rows_hash = @rows = @columns = nil
411
431
  end
412
432
 
413
- def columns
433
+ def columns #:nodoc:
414
434
  @columns ||= cell_matrix.transpose.map do |cell_row|
415
435
  @cells_class.new(self, cell_row)
416
436
  end.freeze
417
437
  end
418
438
 
419
- def new_cell(raw_cell, line)
439
+ def new_cell(raw_cell, line) #:nodoc:
420
440
  @cell_class.new(raw_cell, self, line)
421
441
  end
422
442
 
423
443
  # Pads our own cell_matrix and returns a cell matrix of same
424
444
  # column width that can be used for diffing
425
- def pad!(other_cell_matrix)
445
+ def pad!(other_cell_matrix) #:nodoc:
426
446
  clear_cache!
427
447
  cols = cell_matrix.transpose
428
448
  unmapped_cols = other_cell_matrix.transpose
@@ -460,38 +480,38 @@ module Cucumber
460
480
  (mapped_cols + unmapped_cols).transpose
461
481
  end
462
482
 
463
- def ensure_table(table_or_array)
483
+ def ensure_table(table_or_array) #:nodoc:
464
484
  return table_or_array if Table === table_or_array
465
485
  table_or_array = hashes_to_array(table_or_array) if Hash === table_or_array[0]
466
486
  table_or_array = enumerable_to_array(table_or_array) unless Array == table_or_array[0]
467
487
  Table.new(table_or_array)
468
488
  end
469
489
 
470
- def hashes_to_array(hashes)
490
+ def hashes_to_array(hashes) #:nodoc:
471
491
  header = hashes[0].keys
472
492
  [header] + hashes.map{|hash| header.map{|key| hash[key]}}
473
493
  end
474
494
 
475
- def enumerable_to_array(rows)
495
+ def enumerable_to_array(rows) #:nodoc:
476
496
  rows.map{|row| row.map{|cell| cell}}
477
497
  end
478
498
 
479
- def ensure_green!
499
+ def ensure_green! #:nodoc:
480
500
  each_cell{|cell| cell.status = :passed}
481
501
  end
482
502
 
483
- def each_cell(&proc)
503
+ def each_cell(&proc) #:nodoc:
484
504
  cell_matrix.each{|row| row.each(&proc)}
485
505
  end
486
506
 
487
- def mark_as_missing(col)
507
+ def mark_as_missing(col) #:nodoc:
488
508
  col.each do |cell|
489
509
  cell.status = :undefined
490
510
  end
491
511
  end
492
512
 
493
513
  # Represents a row of cells or columns of cells
494
- class Cells
514
+ class Cells #:nodoc:
495
515
  include Enumerable
496
516
  attr_reader :exception
497
517
 
@@ -547,7 +567,7 @@ module Cucumber
547
567
  end
548
568
  end
549
569
 
550
- class Cell
570
+ class Cell #:nodoc:
551
571
  attr_reader :line, :table
552
572
  attr_accessor :status, :value
553
573
 
@@ -574,7 +594,7 @@ module Cucumber
574
594
  end
575
595
  end
576
596
 
577
- class SurplusCell < Cell
597
+ class SurplusCell < Cell #:nodoc:
578
598
  def status
579
599
  :comment
580
600
  end
@@ -6,7 +6,7 @@ module Cucumber
6
6
  #
7
7
  # This gets stored internally as <tt>["invoice", "release_2"]</tt>
8
8
  #
9
- class Tags
9
+ class Tags #:nodoc:
10
10
  def self.strip_prefix(tag_name)
11
11
  tag_name =~ /^@(.*)/ ? $1 : tag_name
12
12
  end
@@ -23,7 +23,7 @@ module Cucumber
23
23
  end
24
24
 
25
25
  def accept_hook?(hook)
26
- hook.matches_tag_names?(@tag_names)
26
+ hook.tag_names.empty? || (hook.tag_names.map{|tag| Ast::Tags.strip_prefix(tag)} & @tag_names).any?
27
27
  end
28
28
 
29
29
  def count(tag)
@@ -1,20 +1,17 @@
1
1
  module Cucumber
2
2
  module Ast
3
- # A dumb visitor that implements the whole Visitor API and just walks the tree.
3
+ # Base class for formatters. This class just walks the tree depth first.
4
+ # Just override the methods you care about. Remember to call super if you
5
+ # override a method.
4
6
  class Visitor
5
- attr_accessor :options
6
- attr_reader :step_mother
7
+ attr_accessor :options #:nodoc:
8
+ attr_reader :step_mother #:nodoc:
7
9
 
8
10
  def initialize(step_mother)
9
11
  @options = {}
10
12
  @step_mother = step_mother
11
13
  end
12
14
 
13
- def matches_scenario_names?(node)
14
- scenario_name_regexps = options[:name_regexps] || []
15
- scenario_name_regexps.empty? || node.matches_scenario_names?(scenario_name_regexps)
16
- end
17
-
18
15
  def visit_features(features)
19
16
  features.accept(self)
20
17
  end
@@ -109,6 +106,7 @@ module Cucumber
109
106
  def visit_table_cell_value(value, status)
110
107
  end
111
108
 
109
+ # Print +announcement+. This method can be called from within StepDefinitions.
112
110
  def announce(announcement)
113
111
  end
114
112
 
@@ -1,5 +1,5 @@
1
1
  module Cucumber
2
- class Broadcaster
2
+ class Broadcaster #:nodoc:
3
3
  def initialize(receivers = [])
4
4
  @receivers = receivers
5
5
  end
@@ -23,7 +23,7 @@ http://wiki.github.com/aslakhellesoy/cucumber/spoken-languages
23
23
  end
24
24
 
25
25
  def self.list_keywords(io, lang)
26
- language = Parser::NaturalLanguage[lang]
26
+ language = Parser::NaturalLanguage.get(nil, lang)
27
27
  raw = Parser::NaturalLanguage::KEYWORD_KEYS.map do |key|
28
28
  [key, language.keywords(key)]
29
29
  end
@@ -1,6 +1,7 @@
1
1
  require 'optparse'
2
2
  require 'cucumber'
3
3
  require 'ostruct'
4
+ require 'logger'
4
5
  require 'cucumber/parser'
5
6
  require 'cucumber/feature_file'
6
7
  require 'cucumber/formatter/color_io'
@@ -13,6 +14,12 @@ module Cucumber
13
14
  class Main
14
15
  FAILURE = 1
15
16
 
17
+ class LogFormatter < ::Logger::Formatter
18
+ def call(severity, time, progname, msg)
19
+ msg
20
+ end
21
+ end
22
+
16
23
  class << self
17
24
  def step_mother
18
25
  @step_mother ||= StepMother.new
@@ -27,8 +34,6 @@ module Cucumber
27
34
  @args = args
28
35
  @out_stream = out_stream == STDOUT ? Formatter::ColorIO.new : out_stream
29
36
  @error_stream = error_stream
30
- $err = error_stream
31
- @unsupported_programming_languages = []
32
37
  end
33
38
 
34
39
  def execute!(step_mother)
@@ -41,13 +46,19 @@ module Cucumber
41
46
  end
42
47
  end
43
48
  step_mother.options = configuration.options
49
+
50
+ logger = Logger.new(@out_stream)
51
+ logger.formatter = LogFormatter.new
52
+ logger.level = Logger::INFO
53
+ logger.level = Logger::DEBUG if configuration.verbose?
54
+ step_mother.log = logger
44
55
 
45
56
  # Feature files must be loaded before files are required.
46
57
  # This is because i18n step methods are only aliased when
47
58
  # features are loaded. If we swap the order, the requires
48
59
  # will fail.
49
- features = load_plain_text_features(step_mother)
50
- load_step_defs(step_mother)
60
+ features = step_mother.load_plain_text_features(configuration.feature_files)
61
+ step_mother.load_code_files(configuration.step_defs_to_load)
51
62
  enable_diffing
52
63
 
53
64
  visitor = configuration.build_formatter_broadcaster(step_mother)
@@ -80,22 +91,6 @@ module Cucumber
80
91
  exceeded
81
92
  end
82
93
 
83
- def load_plain_text_features(step_mother)
84
- features = Ast::Features.new
85
-
86
- verbose_log("Features:")
87
- configuration.feature_files.each do |f|
88
- feature_file = FeatureFile.new(f)
89
- feature = feature_file.parse(step_mother, configuration.options)
90
- if feature
91
- features.add_feature(feature)
92
- verbose_log(" * #{f}")
93
- end
94
- end
95
- verbose_log("\n")
96
- features
97
- end
98
-
99
94
  def configuration
100
95
  return @configuration if @configuration
101
96
 
@@ -110,38 +105,6 @@ module Cucumber
110
105
 
111
106
  private
112
107
 
113
- def load_step_defs(step_mother)
114
- step_def_files = configuration.step_defs_to_load
115
- verbose_log("Step Definitions:")
116
- step_def_files.each do |step_def_file|
117
- load_step_def(step_mother, step_def_file)
118
- end
119
- verbose_log("\n")
120
- end
121
-
122
- def load_step_def(step_mother, step_def_file)
123
- if programming_language = programming_language_for(step_mother, step_def_file)
124
- verbose_log(" * #{step_def_file}")
125
- programming_language.load_step_def_file(step_def_file)
126
- else
127
- verbose_log(" * #{step_def_file} [NOT SUPPORTED]")
128
- end
129
- end
130
-
131
- def programming_language_for(step_mother, step_def_file) # :nodoc:
132
- if ext = File.extname(step_def_file)[1..-1]
133
- return nil if @unsupported_programming_languages.index(ext)
134
- begin
135
- step_mother.load_programming_language(ext)
136
- rescue LoadError
137
- @unsupported_programming_languages << ext
138
- nil
139
- end
140
- else
141
- nil
142
- end
143
- end
144
-
145
108
  def enable_diffing
146
109
  if configuration.diff_enabled?
147
110
  begin
@@ -1,5 +1,5 @@
1
1
  module Cucumber
2
- module Constantize
2
+ module Constantize #:nodoc:
3
3
  def constantize(camel_cased_word)
4
4
  begin
5
5
  names = camel_cased_word.split('::')
@@ -18,7 +18,7 @@
18
18
  #
19
19
  # All backtrace munging can be turned off with the <tt>--backtrace</tt> switch
20
20
  #
21
- class Exception
21
+ class Exception #:nodoc:
22
22
  CUCUMBER_FILTER_PATTERNS = [
23
23
  /vendor\/rails|lib\/cucumber|bin\/cucumber:|lib\/rspec|gems\//
24
24
  ]
@@ -1,11 +1,13 @@
1
1
  require 'cucumber/platform'
2
2
 
3
3
  module Cucumber
4
+ # Raised if the number of a StepDefinition's Regexp match groups
5
+ # is different from the number of Proc arguments.
4
6
  class ArityMismatchError < StandardError
5
7
  end
6
8
  end
7
9
 
8
- class Object
10
+ class Object #:nodoc:
9
11
  def cucumber_instance_exec(check_arity, pseudo_method, *args, &block)
10
12
  cucumber_run_with_backtrace_filtering(pseudo_method) do
11
13
  if check_arity && !cucumber_compatible_arity?(args, block)
@@ -23,7 +25,9 @@ class Object
23
25
  end
24
26
  end
25
27
  end
26
-
28
+
29
+ private
30
+
27
31
  def cucumber_arity(block)
28
32
  a = block.arity
29
33
  Cucumber::RUBY_1_9 ? a : (a == -1 ? 0 : a)
@@ -48,7 +52,8 @@ class Object
48
52
 
49
53
  unless defined? instance_exec # 1.9
50
54
  # http://eigenclass.org/hiki/bounded+space+instance_exec
51
- module InstanceExecHelper; end
55
+ module InstanceExecHelper #:nodoc:
56
+ end
52
57
  include InstanceExecHelper
53
58
  def instance_exec(*args, &block)
54
59
  begin
@@ -1,5 +1,5 @@
1
1
  # Proc extension to get more location info out of a proc
2
- class Proc
2
+ class Proc #:nodoc:
3
3
  PROC_PATTERN = /[\d\w]+@(.*):(.*)>/
4
4
 
5
5
  def to_comment_line
@@ -1,4 +1,4 @@
1
- class String
1
+ class String #:nodoc:
2
2
  def indent(n)
3
3
  if n >= 0
4
4
  gsub(/^/, ' ' * n)
@@ -3,10 +3,11 @@ require 'cucumber/filter'
3
3
 
4
4
  module Cucumber
5
5
  class FeatureFile
6
- FILE_COLON_LINE_PATTERN = /^([\w\W]*?):([\d:]+)$/
7
- LANGUAGE_PATTERN = /language:\s*(.*)/
6
+ FILE_COLON_LINE_PATTERN = /^([\w\W]*?):([\d:]+)$/ #:nodoc:
7
+ LANGUAGE_PATTERN = /language:\s*(.*)/ #:nodoc:
8
8
 
9
- # The +uri+ argument can ba a path or a path:line1:line2 etc.
9
+ # The +uri+ argument is the location of the source. It can ba a path
10
+ # or a path:line1:line2 etc. If +source+ is passed, +uri+ is ignored.
10
11
  def initialize(uri, source=nil)
11
12
  @source = source
12
13
  _, @path, @lines = *FILE_COLON_LINE_PATTERN.match(uri)
@@ -1,5 +1,6 @@
1
1
  module Cucumber
2
- class Filter
2
+ # Filters the AST based on --tags and --name
3
+ class Filter #:nodoc:
3
4
  def initialize(lines, options)
4
5
  @lines = lines
5
6
 
@@ -23,8 +23,9 @@ Term::ANSIColor.coloring = false if !STDOUT.tty? and not ENV.has_key?("AUTOTEST"
23
23
 
24
24
  module Cucumber
25
25
  module Formatter
26
- # Defines aliases for coloured output. You can tweak the colours by defining
27
- # a <tt>CUCUMBER_COLORS</tt> variable in your shell, very much like you can
26
+ # Defines aliases for coloured output. You don't invoke any methods from this
27
+ # module directly, but you can change the output colours by defining
28
+ # a <tt>CUCUMBER_COLORS</tt> variable in your shell, very much like how you can
28
29
  # tweak the familiar POSIX command <tt>ls</tt> with
29
30
  # <a href="http://mipsisrisc.com/rambling/2008/06/27/lscolorsls_colors-now-with-linux-support/">$LSCOLORS/$LS_COLORS</a>
30
31
  #
@@ -97,7 +98,7 @@ module Cucumber
97
98
  end
98
99
  end
99
100
 
100
- def self.define_grey
101
+ def self.define_grey #:nodoc:
101
102
  begin
102
103
  gem 'genki-ruby-terminfo'
103
104
  require 'terminfo'
@@ -125,8 +126,8 @@ module Cucumber
125
126
  end
126
127
  end
127
128
 
128
- def self.define_real_grey
129
- def grey(m)
129
+ def self.define_real_grey #:nodoc:
130
+ def grey(m) #:nodoc:
130
131
  if ::Term::ANSIColor.coloring?
131
132
  "\e[90m#{m}\e[0m"
132
133
  else
@@ -3,10 +3,10 @@ require 'forwardable'
3
3
  module Cucumber
4
4
  module Formatter
5
5
  # Adapter to make #puts/#print/#flush work with colours on Windows
6
- class ColorIO
6
+ class ColorIO #:nodoc:
7
7
  extend Forwardable
8
8
  def_delegators :@kernel, :puts, :print # win32console colours only work when sent to Kernel
9
- def_delegators :@stdout, :flush, :tty?, :write
9
+ def_delegators :@stdout, :flush, :tty?, :write, :close
10
10
 
11
11
  def initialize
12
12
  @kernel = Kernel
@@ -3,6 +3,8 @@ require 'cucumber/formatter/duration'
3
3
 
4
4
  module Cucumber
5
5
  module Formatter
6
+ # This module contains helper methods that are used by formatters
7
+ # that print output to the terminal.
6
8
  module Console
7
9
  extend ANSIColor
8
10
  include Duration
@@ -1,6 +1,9 @@
1
1
  module Cucumber
2
2
  module Formatter
3
3
  module Duration
4
+ # Helper method for formatters that need to
5
+ # format a duration in seconds to the UNIX
6
+ # <tt>time</tt> format.
4
7
  def format_duration(seconds)
5
8
  m, s = seconds.divmod(60)
6
9
  "#{m}m#{'%.3f' % s}s"
@@ -3,6 +3,7 @@ require 'cucumber/formatter/duration'
3
3
 
4
4
  module Cucumber
5
5
  module Formatter
6
+ # The formatter used for <tt>--format html</tt>
6
7
  class Html < Ast::Visitor
7
8
  include ERB::Util # for the #h method
8
9
  include Duration
@@ -2,6 +2,7 @@ require 'cucumber/formatter/ordered_xml_markup'
2
2
 
3
3
  module Cucumber
4
4
  module Formatter
5
+ # The formatter used for <tt>--format junit</tt>
5
6
  class Junit < Cucumber::Ast::Visitor
6
7
 
7
8
  def initialize(step_mother, io, options)
@@ -8,7 +8,7 @@ end
8
8
  module Cucumber
9
9
  module Formatter
10
10
  # Emits attributes ordered alphabetically, so that we can predicatbly test output.
11
- class OrderedXmlMarkup < Builder::XmlMarkup
11
+ class OrderedXmlMarkup < Builder::XmlMarkup #:nodoc:
12
12
  def _insert_attributes(attrs, order=[])
13
13
  return if attrs.nil?
14
14
  keys = attrs.keys.map{|k| k.to_s}