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.
- data/History.txt +22 -3
- data/License.txt +2 -0
- data/Manifest.txt +9 -5
- data/config/hoe.rb +1 -0
- data/examples/i18n/Rakefile +5 -3
- data/examples/i18n/fi/features/yhteenlasku.feature +5 -4
- data/examples/python/features/step_definitions/fib_steps.py +3 -0
- data/examples/python/features/support/env.rb +21 -21
- data/gem_tasks/contributors.rake +8 -0
- data/gem_tasks/features.rake +1 -0
- data/gem_tasks/sdoc.rake +7 -0
- data/lib/README.rdoc +12 -0
- data/lib/cucumber/ast/background.rb +1 -1
- data/lib/cucumber/ast/comment.rb +1 -1
- data/lib/cucumber/ast/examples.rb +9 -4
- data/lib/cucumber/ast/feature.rb +1 -1
- data/lib/cucumber/ast/feature_element.rb +1 -1
- data/lib/cucumber/ast/features.rb +1 -1
- data/lib/cucumber/ast/outline_table.rb +2 -2
- data/lib/cucumber/ast/py_string.rb +1 -1
- data/lib/cucumber/ast/scenario.rb +1 -1
- data/lib/cucumber/ast/scenario_outline.rb +8 -7
- data/lib/cucumber/ast/step.rb +1 -1
- data/lib/cucumber/ast/step_collection.rb +1 -1
- data/lib/cucumber/ast/step_invocation.rb +1 -1
- data/lib/cucumber/ast/table.rb +65 -45
- data/lib/cucumber/ast/tags.rb +2 -2
- data/lib/cucumber/ast/visitor.rb +6 -8
- data/lib/cucumber/broadcaster.rb +1 -1
- data/lib/cucumber/cli/language_help_formatter.rb +1 -1
- data/lib/cucumber/cli/main.rb +15 -52
- data/lib/cucumber/constantize.rb +1 -1
- data/lib/cucumber/core_ext/exception.rb +1 -1
- data/lib/cucumber/core_ext/instance_exec.rb +8 -3
- data/lib/cucumber/core_ext/proc.rb +1 -1
- data/lib/cucumber/core_ext/string.rb +1 -1
- data/lib/cucumber/feature_file.rb +4 -3
- data/lib/cucumber/filter.rb +2 -1
- data/lib/cucumber/formatter/ansicolor.rb +6 -5
- data/lib/cucumber/formatter/color_io.rb +2 -2
- data/lib/cucumber/formatter/console.rb +2 -0
- data/lib/cucumber/formatter/duration.rb +3 -0
- data/lib/cucumber/formatter/html.rb +1 -0
- data/lib/cucumber/formatter/junit.rb +1 -0
- data/lib/cucumber/formatter/ordered_xml_markup.rb +1 -1
- data/lib/cucumber/formatter/pretty.rb +18 -4
- data/lib/cucumber/formatter/profile.rb +1 -0
- data/lib/cucumber/formatter/progress.rb +1 -0
- data/lib/cucumber/formatter/rerun.rb +2 -0
- data/lib/cucumber/formatter/steps.rb +1 -0
- data/lib/cucumber/formatter/tag_cloud.rb +2 -1
- data/lib/cucumber/formatter/unicode.rb +1 -1
- data/lib/cucumber/formatter/usage.rb +1 -0
- data/lib/cucumber/language_support/language_methods.rb +34 -12
- data/lib/cucumber/language_support.rb +30 -0
- data/lib/cucumber/parser/feature.rb +81 -57
- data/lib/cucumber/parser/feature.tt +3 -3
- data/lib/cucumber/parser/natural_language.rb +1 -1
- data/lib/cucumber/parser/table.rb +3 -0
- data/lib/cucumber/parser/treetop_ext.rb +6 -5
- data/lib/cucumber/platform.rb +1 -2
- data/lib/cucumber/py_support/py_dsl.py +8 -0
- data/lib/cucumber/py_support/py_language.py +2 -0
- data/lib/cucumber/py_support/py_language.rb +68 -0
- data/lib/cucumber/rails/world.rb +2 -1
- data/lib/cucumber/rake/task.rb +13 -11
- data/lib/cucumber/rb_support/rb_dsl.rb +27 -15
- data/lib/cucumber/rb_support/rb_hook.rb +1 -2
- data/lib/cucumber/rb_support/rb_language.rb +57 -33
- data/lib/cucumber/rb_support/rb_step_definition.rb +42 -38
- data/lib/cucumber/rb_support/rb_world.rb +93 -0
- data/lib/cucumber/rspec_neuter.rb +3 -3
- data/lib/cucumber/step_match.rb +2 -2
- data/lib/cucumber/step_mother.rb +91 -65
- data/lib/cucumber/version.rb +1 -1
- data/lib/cucumber/webrat/element_locator.rb +3 -3
- data/rails_generators/cucumber/templates/cucumber.rake +2 -0
- data/rails_generators/cucumber/templates/en/webrat_steps.rb +4 -0
- data/spec/cucumber/ast/background_spec.rb +8 -1
- data/spec/cucumber/ast/scenario_outline_spec.rb +1 -0
- data/spec/cucumber/ast/table_spec.rb +10 -0
- data/spec/cucumber/cli/options_spec.rb +1 -1
- data/spec/cucumber/parser/feature_parser_spec.rb +4 -0
- data/spec/cucumber/rb_support/rb_step_definition_spec.rb +114 -0
- data/spec/cucumber/step_mother_spec.rb +29 -10
- data/spec/cucumber/treetop_parser/with_comments.feature +14 -1
- data/spec/cucumber/world/pending_spec.rb +1 -1
- metadata +21 -7
- data/gem_tasks/yard.rake +0 -8
- data/lib/cucumber/language_support/hook_methods.rb +0 -9
- data/lib/cucumber/world.rb +0 -89
- data/spec/cucumber/ast/visitor_spec.rb +0 -27
- data/spec/cucumber/step_definition_spec.rb +0 -102
data/lib/cucumber/ast/table.rb
CHANGED
@@ -1,11 +1,23 @@
|
|
1
1
|
module Cucumber
|
2
2
|
module Ast
|
3
|
-
#
|
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
|
-
#
|
6
|
-
# | c | d |
|
8
|
+
# For example:
|
7
9
|
#
|
8
|
-
#
|
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
|
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
|
-
#
|
39
|
-
#
|
56
|
+
# | a | 7 | 4 |
|
57
|
+
# | b | 9 | 2 |
|
40
58
|
#
|
41
59
|
# Gets converted into the following:
|
42
60
|
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
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
|
-
|
153
|
-
|
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
|
-
#
|
208
|
-
#
|
209
|
-
#
|
210
|
-
#
|
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
|
data/lib/cucumber/ast/tags.rb
CHANGED
@@ -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.
|
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)
|
data/lib/cucumber/ast/visitor.rb
CHANGED
@@ -1,20 +1,17 @@
|
|
1
1
|
module Cucumber
|
2
2
|
module Ast
|
3
|
-
#
|
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
|
|
data/lib/cucumber/broadcaster.rb
CHANGED
@@ -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
|
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
|
data/lib/cucumber/cli/main.rb
CHANGED
@@ -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(
|
50
|
-
|
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
|
data/lib/cucumber/constantize.rb
CHANGED
@@ -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
|
55
|
+
module InstanceExecHelper #:nodoc:
|
56
|
+
end
|
52
57
|
include InstanceExecHelper
|
53
58
|
def instance_exec(*args, &block)
|
54
59
|
begin
|
@@ -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
|
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)
|
data/lib/cucumber/filter.rb
CHANGED
@@ -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
|
27
|
-
#
|
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
|
@@ -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}
|