cucumber 3.2.0 → 4.0.0.rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +61 -18
  3. data/CONTRIBUTING.md +1 -0
  4. data/bin/cucumber +1 -1
  5. data/lib/autotest/cucumber_mixin.rb +42 -39
  6. data/lib/cucumber/cli/configuration.rb +4 -4
  7. data/lib/cucumber/cli/main.rb +11 -12
  8. data/lib/cucumber/cli/options.rb +56 -69
  9. data/lib/cucumber/cli/profile_loader.rb +32 -20
  10. data/lib/cucumber/configuration.rb +20 -21
  11. data/lib/cucumber/constantize.rb +2 -5
  12. data/lib/cucumber/deprecate.rb +5 -5
  13. data/lib/cucumber/errors.rb +4 -6
  14. data/lib/cucumber/events.rb +1 -0
  15. data/lib/cucumber/events/gherkin_source_parsed.rb +11 -0
  16. data/lib/cucumber/events/step_activated.rb +2 -1
  17. data/lib/cucumber/file_specs.rb +6 -6
  18. data/lib/cucumber/filters/activate_steps.rb +5 -3
  19. data/lib/cucumber/filters/prepare_world.rb +5 -9
  20. data/lib/cucumber/filters/quit.rb +1 -3
  21. data/lib/cucumber/filters/tag_limits/verifier.rb +2 -4
  22. data/lib/cucumber/formatter/ansicolor.rb +40 -45
  23. data/lib/cucumber/formatter/ast_lookup.rb +160 -0
  24. data/lib/cucumber/formatter/backtrace_filter.rb +5 -7
  25. data/lib/cucumber/formatter/console.rb +28 -59
  26. data/lib/cucumber/formatter/console_counts.rb +4 -9
  27. data/lib/cucumber/formatter/console_issues.rb +6 -3
  28. data/lib/cucumber/formatter/duration_extractor.rb +1 -1
  29. data/lib/cucumber/formatter/fanout.rb +2 -0
  30. data/lib/cucumber/formatter/ignore_missing_messages.rb +1 -1
  31. data/lib/cucumber/formatter/interceptor.rb +5 -7
  32. data/lib/cucumber/formatter/io.rb +8 -14
  33. data/lib/cucumber/formatter/json.rb +93 -117
  34. data/lib/cucumber/formatter/junit.rb +55 -57
  35. data/lib/cucumber/formatter/pretty.rb +346 -152
  36. data/lib/cucumber/formatter/progress.rb +28 -32
  37. data/lib/cucumber/formatter/rerun.rb +22 -4
  38. data/lib/cucumber/formatter/stepdefs.rb +1 -2
  39. data/lib/cucumber/formatter/steps.rb +2 -3
  40. data/lib/cucumber/formatter/summary.rb +16 -8
  41. data/lib/cucumber/formatter/unicode.rb +15 -17
  42. data/lib/cucumber/formatter/usage.rb +9 -8
  43. data/lib/cucumber/gherkin/data_table_parser.rb +8 -6
  44. data/lib/cucumber/gherkin/formatter/ansi_escapes.rb +13 -17
  45. data/lib/cucumber/gherkin/formatter/escaping.rb +2 -2
  46. data/lib/cucumber/gherkin/steps_parser.rb +7 -8
  47. data/lib/cucumber/glue/dsl.rb +1 -1
  48. data/lib/cucumber/glue/hook.rb +16 -9
  49. data/lib/cucumber/glue/invoke_in_world.rb +13 -18
  50. data/lib/cucumber/glue/proto_world.rb +14 -16
  51. data/lib/cucumber/glue/registry_and_more.rb +7 -9
  52. data/lib/cucumber/glue/snippet.rb +21 -20
  53. data/lib/cucumber/glue/step_definition.rb +14 -15
  54. data/lib/cucumber/glue/world_factory.rb +1 -1
  55. data/lib/cucumber/hooks.rb +11 -11
  56. data/lib/cucumber/multiline_argument.rb +4 -6
  57. data/lib/cucumber/multiline_argument/data_table.rb +88 -59
  58. data/lib/cucumber/multiline_argument/data_table/diff_matrices.rb +1 -1
  59. data/lib/cucumber/multiline_argument/doc_string.rb +1 -1
  60. data/lib/cucumber/platform.rb +3 -3
  61. data/lib/cucumber/rake/task.rb +13 -16
  62. data/lib/cucumber/rspec/disable_option_parser.rb +9 -8
  63. data/lib/cucumber/running_test_case.rb +2 -53
  64. data/lib/cucumber/runtime.rb +27 -57
  65. data/lib/cucumber/runtime/after_hooks.rb +3 -3
  66. data/lib/cucumber/runtime/before_hooks.rb +3 -3
  67. data/lib/cucumber/runtime/for_programming_languages.rb +3 -2
  68. data/lib/cucumber/runtime/step_hooks.rb +1 -1
  69. data/lib/cucumber/runtime/support_code.rb +10 -12
  70. data/lib/cucumber/runtime/user_interface.rb +4 -6
  71. data/lib/cucumber/step_definition_light.rb +4 -3
  72. data/lib/cucumber/step_match.rb +12 -11
  73. data/lib/cucumber/step_match_search.rb +2 -1
  74. data/lib/cucumber/term/ansicolor.rb +9 -9
  75. data/lib/cucumber/version +1 -1
  76. metadata +37 -28
  77. data/lib/cucumber/formatter/cucumber.css +0 -286
  78. data/lib/cucumber/formatter/cucumber.sass +0 -247
  79. data/lib/cucumber/formatter/hook_query_visitor.rb +0 -42
  80. data/lib/cucumber/formatter/html.rb +0 -611
  81. data/lib/cucumber/formatter/html_builder.rb +0 -121
  82. data/lib/cucumber/formatter/http_io.rb +0 -146
  83. data/lib/cucumber/formatter/inline-js.js +0 -30
  84. data/lib/cucumber/formatter/jquery-min.js +0 -154
  85. data/lib/cucumber/formatter/json_pretty.rb +0 -11
  86. data/lib/cucumber/formatter/legacy_api/adapter.rb +0 -1028
  87. data/lib/cucumber/formatter/legacy_api/ast.rb +0 -394
  88. data/lib/cucumber/formatter/legacy_api/results.rb +0 -50
  89. data/lib/cucumber/formatter/legacy_api/runtime_facade.rb +0 -32
  90. data/lib/cucumber/step_argument.rb +0 -25
@@ -10,7 +10,7 @@ module Cucumber
10
10
  end
11
11
 
12
12
  def raise_nil_world
13
- raise NilWorld.new
13
+ raise NilWorld
14
14
  rescue NilWorld => e
15
15
  e.backtrace.clear
16
16
  e.backtrace.push(Glue.backtrace_line(@proc, 'World'))
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'pathname'
4
- require 'cucumber/core/ast/location'
4
+ require 'cucumber/core/test/location'
5
5
  require 'cucumber/core/test/around_hook'
6
6
 
7
7
  module Cucumber
@@ -9,29 +9,29 @@ module Cucumber
9
9
  # source for test steps
10
10
  module Hooks
11
11
  class << self
12
- def before_hook(source, location, &block)
13
- build_hook_step(source, location, block, BeforeHook, Core::Test::UnskippableAction)
12
+ def before_hook(location, &block)
13
+ build_hook_step(location, block, BeforeHook, Core::Test::UnskippableAction)
14
14
  end
15
15
 
16
- def after_hook(source, location, &block)
17
- build_hook_step(source, location, block, AfterHook, Core::Test::UnskippableAction)
16
+ def after_hook(location, &block)
17
+ build_hook_step(location, block, AfterHook, Core::Test::UnskippableAction)
18
18
  end
19
19
 
20
- def after_step_hook(source, location, &block)
21
- raise ArgumentError unless source.last.is_a?(Core::Ast::Step)
22
- build_hook_step(source, location, block, AfterStepHook, Core::Test::Action)
20
+ def after_step_hook(test_step, location, &block)
21
+ raise ArgumentError if test_step.hook?
22
+ build_hook_step(location, block, AfterStepHook, Core::Test::Action)
23
23
  end
24
24
 
25
- def around_hook(_source, &block)
25
+ def around_hook(&block)
26
26
  Core::Test::AroundHook.new(&block)
27
27
  end
28
28
 
29
29
  private
30
30
 
31
- def build_hook_step(source, location, block, hook_type, action_type)
31
+ def build_hook_step(location, block, hook_type, action_type)
32
32
  action = action_type.new(location, &block)
33
33
  hook = hook_type.new(action.location)
34
- Core::Test::Step.new(source + [hook], action)
34
+ Core::Test::HookStep.new(hook.text, location, action)
35
35
  end
36
36
  end
37
37
 
@@ -12,10 +12,10 @@ module Cucumber
12
12
  end
13
13
 
14
14
  def from(argument, location = nil, content_type = nil)
15
- location ||= Core::Ast::Location.of_caller
15
+ location ||= Core::Test::Location.of_caller
16
16
  case argument
17
17
  when String
18
- builder.doc_string(Core::Ast::DocString.new(argument, content_type, location))
18
+ builder.doc_string(Core::Test::DocString.new(argument, content_type, location))
19
19
  when Array
20
20
  location = location.on_line(argument.first.line..argument.last.line)
21
21
  builder.data_table(argument.map(&:cells), location)
@@ -52,11 +52,9 @@ module Cucumber
52
52
  end
53
53
 
54
54
  class None
55
- def append_to(array)
56
- end
55
+ def append_to(array); end
57
56
 
58
- def describe_to(visitor)
59
- end
57
+ def describe_to(visitor); end
60
58
  end
61
59
  end
62
60
  end
@@ -3,7 +3,6 @@
3
3
  require 'forwardable'
4
4
  require 'cucumber/gherkin/data_table_parser'
5
5
  require 'cucumber/gherkin/formatter/escaping'
6
- require 'cucumber/core/ast/describes_itself'
7
6
  require 'cucumber/multiline_argument/data_table/diff_matrices'
8
7
 
9
8
  module Cucumber
@@ -28,14 +27,16 @@ module Cucumber
28
27
  # This will store <tt>[['a', 'b'], ['c', 'd']]</tt> in the <tt>data</tt> variable.
29
28
  #
30
29
  class DataTable
31
- include Core::Ast::DescribesItself
32
-
33
30
  def self.default_arg_name #:nodoc:
34
31
  'table'
35
32
  end
36
33
 
34
+ def describe_to(visitor, *args)
35
+ visitor.legacy_table(self, *args)
36
+ end
37
+
37
38
  class << self
38
- def from(data, location = Core::Ast::Location.of_caller)
39
+ def from(data, location = Core::Test::Location.of_caller)
39
40
  case data
40
41
  when Array
41
42
  from_array(data, location)
@@ -48,15 +49,15 @@ module Cucumber
48
49
 
49
50
  private
50
51
 
51
- def parse(text, location = Core::Ast::Location.of_caller)
52
+ def parse(text, location = Core::Test::Location.of_caller)
52
53
  builder = Builder.new
53
54
  parser = Cucumber::Gherkin::DataTableParser.new(builder)
54
55
  parser.parse(text)
55
56
  from_array(builder.rows, location)
56
57
  end
57
58
 
58
- def from_array(data, location = Core::Ast::Location.of_caller)
59
- new Core::Ast::DataTable.new(data, location)
59
+ def from_array(data, location = Core::Test::Location.of_caller)
60
+ new Core::Test::DataTable.new(data, location)
60
61
  end
61
62
  end
62
63
 
@@ -71,18 +72,17 @@ module Cucumber
71
72
  @rows << row
72
73
  end
73
74
 
74
- def eof
75
- end
75
+ def eof; end
76
76
  end
77
77
 
78
- NULL_CONVERSIONS = Hash.new({ :strict => false, :proc => lambda { |cell_value| cell_value } }).freeze
78
+ NULL_CONVERSIONS = Hash.new(strict: false, proc: ->(cell_value) { cell_value }).freeze
79
79
 
80
- # @param data [Core::Ast::DataTable] the data for the table
80
+ # @param data [Core::Test::DataTable] the data for the table
81
81
  # @param conversion_procs [Hash] see map_columns!
82
82
  # @param header_mappings [Hash] see map_headers!
83
83
  # @param header_conversion_proc [Proc] see map_headers!
84
84
  def initialize(data, conversion_procs = NULL_CONVERSIONS.dup, header_mappings = {}, header_conversion_proc = nil)
85
- raise ArgumentError, 'data must be a Core::Ast::DataTable' unless data.is_a? Core::Ast::DataTable
85
+ raise ArgumentError, 'data must be a Core::Test::DataTable' unless data.is_a? Core::Test::DataTable
86
86
  ast_table = data
87
87
  # Verify that it's square
88
88
  ast_table.transpose
@@ -111,7 +111,7 @@ module Cucumber
111
111
  # registered with #map_column! and #map_headers!.
112
112
  #
113
113
  def dup
114
- self.class.new(Core::Ast::DataTable.new(raw, location), @conversion_procs.dup, @header_mappings.dup, @header_conversion_proc)
114
+ self.class.new(Core::Test::DataTable.new(raw, location), @conversion_procs.dup, @header_mappings.dup, @header_conversion_proc)
115
115
  end
116
116
 
117
117
  # Returns a new, transposed table. Example:
@@ -126,7 +126,7 @@ module Cucumber
126
126
  # | 4 | 2 |
127
127
  #
128
128
  def transpose
129
- self.class.new(Core::Ast::DataTable.new(raw.transpose, location), @conversion_procs.dup, @header_mappings.dup, @header_conversion_proc)
129
+ self.class.new(Core::Test::DataTable.new(raw.transpose, location), @conversion_procs.dup, @header_mappings.dup, @header_conversion_proc)
130
130
  end
131
131
 
132
132
  # Converts this table into an Array of Hash where the keys of each
@@ -160,7 +160,7 @@ module Cucumber
160
160
  #
161
161
  def symbolic_hashes
162
162
  @symbolic_hashes ||=
163
- self.hashes.map do |string_hash|
163
+ hashes.map do |string_hash|
164
164
  Hash[string_hash.map { |a, b| [symbolize_key(a), b] }]
165
165
  end
166
166
  end
@@ -180,7 +180,7 @@ module Cucumber
180
180
  def rows_hash
181
181
  return @rows_hash if @rows_hash
182
182
  verify_table_width(2)
183
- @rows_hash = self.transpose.hashes[0]
183
+ @rows_hash = transpose.hashes[0]
184
184
  end
185
185
 
186
186
  # Gets the raw data of this table. For example, a Table built from
@@ -200,7 +200,7 @@ module Cucumber
200
200
  end
201
201
 
202
202
  def column_names #:nodoc:
203
- @col_names ||= cell_matrix[0].map(&:value)
203
+ @column_names ||= cell_matrix[0].map(&:value)
204
204
  end
205
205
 
206
206
  def rows
@@ -269,7 +269,7 @@ module Cucumber
269
269
 
270
270
  # Returns a new Table where the headers are redefined. See #map_headers!
271
271
  def map_headers(mappings = {}, &block)
272
- self.class.new(Core::Ast::DataTable.new(raw, location), @conversion_procs.dup, mappings, block)
272
+ self.class.new(Core::Test::DataTable.new(raw, location), @conversion_procs.dup, mappings, block)
273
273
  end
274
274
 
275
275
  # Change how #hashes converts column values. The +column_name+ argument identifies the column
@@ -286,15 +286,15 @@ module Cucumber
286
286
  #
287
287
  def map_column!(column_name, strict = true, &conversion_proc)
288
288
  # TODO: Remove this method for 2.0
289
- @conversion_procs[column_name.to_s] = { :strict => strict, :proc => conversion_proc }
289
+ @conversion_procs[column_name.to_s] = { strict: strict, proc: conversion_proc }
290
290
  self
291
291
  end
292
292
 
293
293
  # Returns a new Table with an additional column mapping. See #map_column!
294
294
  def map_column(column_name, strict = true, &conversion_proc)
295
295
  conversion_procs = @conversion_procs.dup
296
- conversion_procs[column_name.to_s] = { :strict => strict, :proc => conversion_proc }
297
- self.class.new(Core::Ast::DataTable.new(raw, location), conversion_procs, @header_mappings.dup, @header_conversion_proc)
296
+ conversion_procs[column_name.to_s] = { strict: strict, proc: conversion_proc }
297
+ self.class.new(Core::Test::DataTable.new(raw, location), conversion_procs, @header_mappings.dup, @header_conversion_proc)
298
298
  end
299
299
 
300
300
  # Compares +other_table+ to self. If +other_table+ contains columns
@@ -353,8 +353,8 @@ module Cucumber
353
353
  end
354
354
 
355
355
  def to_hash(cells) #:nodoc:
356
- hash = Hash.new do |hash, key|
357
- hash[key.to_s] if key.is_a?(Symbol)
356
+ hash = Hash.new do |hash_inner, key|
357
+ hash_inner[key.to_s] if key.is_a?(Symbol)
358
358
  end
359
359
  column_names.each_with_index do |column_name, column_index|
360
360
  hash[column_name] = cells.value(column_index)
@@ -367,19 +367,21 @@ module Cucumber
367
367
  end
368
368
 
369
369
  def verify_column(column_name) #:nodoc:
370
- raise %{The column named "#{column_name}" does not exist} unless raw[0].include?(column_name)
370
+ raise %(The column named "#{column_name}" does not exist) unless raw[0].include?(column_name)
371
371
  end
372
372
 
373
373
  def verify_table_width(width) #:nodoc:
374
- raise %{The table must have exactly #{width} columns} unless raw[0].size == width
374
+ raise %(The table must have exactly #{width} columns) unless raw[0].size == width
375
375
  end
376
376
 
377
- def has_text?(text) #:nodoc:
377
+ # TODO: remove the below function if it's not actually being used.
378
+ # Nothing else in this repo calls it.
379
+ def text?(text) #:nodoc:
378
380
  raw.flatten.compact.detect { |cell_value| cell_value.index(text) }
379
381
  end
380
382
 
381
383
  def cells_rows #:nodoc:
382
- @rows ||= cell_matrix.map do |cell_row|
384
+ @rows ||= cell_matrix.map do |cell_row| # rubocop:disable Naming/MemoizedInstanceVariableName
383
385
  Cells.new(self, cell_row)
384
386
  end
385
387
  end
@@ -399,26 +401,48 @@ module Cucumber
399
401
  end
400
402
 
401
403
  def to_s(options = {}) #:nodoc:
402
- # TODO: factor out this code so we don't depend on such a big lump of old cruft
403
- require 'cucumber/formatter/pretty'
404
- require 'cucumber/formatter/legacy_api/adapter'
405
- options = {:color => true, :indent => 2, :prefixes => TO_S_PREFIXES}.merge(options)
406
- io = StringIO.new
407
-
408
- c = Cucumber::Term::ANSIColor.coloring?
409
- Cucumber::Term::ANSIColor.coloring = options[:color]
410
- runtime = Struct.new(:configuration).new(Configuration.new)
411
- formatter = Formatter::Pretty.new(runtime, io, options)
412
- formatter.instance_variable_set('@indent', options[:indent])
413
- Formatter::LegacyApi::Ast::MultilineArg.for(self).accept(Formatter::Fanout.new([formatter]))
414
- Cucumber::Term::ANSIColor.coloring = c
415
- io.rewind
416
- s = "\n" + io.read + (' ' * (options[:indent] - 2))
417
- s
404
+ indentation = options.key?(:indent) ? options[:indent] : 2
405
+ prefixes = options.key?(:prefixes) ? options[:prefixes] : TO_S_PREFIXES
406
+ DataTablePrinter.new(self, indentation, prefixes).to_s
418
407
  end
419
408
 
420
- def description_for_visitors
421
- :legacy_table
409
+ class DataTablePrinter #:nodoc:
410
+ include Cucumber::Gherkin::Formatter::Escaping
411
+ attr_reader :data_table, :indentation, :prefixes
412
+ private :data_table, :indentation, :prefixes
413
+
414
+ def initialize(data_table, indentation, prefixes)
415
+ @data_table = data_table
416
+ @indentation = indentation
417
+ @prefixes = prefixes
418
+ end
419
+
420
+ def to_s
421
+ leading_row = "\n"
422
+ end_indentation = indentation - 2
423
+ trailing_row = "\n" + (' ' * end_indentation)
424
+ table_rows = data_table.cell_matrix.map { |row| format_row(row) }
425
+ leading_row + table_rows.join("\n") + trailing_row
426
+ end
427
+
428
+ private
429
+
430
+ def format_row(row)
431
+ row_start = (' ' * indentation) + '| '
432
+ row_end = '|'
433
+ cells = row.map.with_index do |cell, i|
434
+ format_cell(cell, data_table.col_width(i))
435
+ end
436
+ row_start + cells.join('| ') + row_end
437
+ end
438
+
439
+ def format_cell(cell, col_width)
440
+ cell_text = escape_cell(cell.value.to_s)
441
+ cell_text_width = cell_text.unpack('U*').length
442
+ padded_text = cell_text + (' ' * (col_width - cell_text_width))
443
+ prefix = prefixes[cell.status]
444
+ "#{prefix}#{padded_text} "
445
+ end
422
446
  end
423
447
 
424
448
  def columns #:nodoc:
@@ -446,7 +470,11 @@ module Cucumber
446
470
 
447
471
  def create_cell_matrix(ast_table) #:nodoc:
448
472
  ast_table.raw.map do |raw_row|
449
- line = raw_row.line rescue -1
473
+ line = begin
474
+ raw_row.line
475
+ rescue StandardError
476
+ -1
477
+ end
450
478
  raw_row.map do |raw_cell|
451
479
  Cell.new(raw_cell, self, line)
452
480
  end
@@ -476,22 +504,20 @@ module Cucumber
476
504
  end
477
505
 
478
506
  @header_mappings.each_pair do |pre, post|
479
- mapped_cells = header_cells.select { |cell| pre === cell.value }
507
+ mapped_cells = header_cells.reject { |cell| cell.value.match(pre).nil? }
480
508
  raise "No headers matched #{pre.inspect}" if mapped_cells.empty?
481
509
  raise "#{mapped_cells.length} headers matched #{pre.inspect}: #{mapped_cells.map(&:value).inspect}" if mapped_cells.length > 1
482
510
  mapped_cells[0].value = post
483
- if @conversion_procs.key?(pre)
484
- @conversion_procs[post] = @conversion_procs.delete(pre)
485
- end
511
+ @conversion_procs[post] = @conversion_procs.delete(pre) if @conversion_procs.key?(pre)
486
512
  end
487
513
  end
488
514
 
489
515
  def clear_cache! #:nodoc:
490
- @hashes = @rows_hash = @col_names = @rows = @columns = nil
516
+ @hashes = @rows_hash = @column_names = @rows = @columns = nil
491
517
  end
492
518
 
493
519
  def ensure_table(table_or_array) #:nodoc:
494
- return table_or_array if DataTable === table_or_array
520
+ return table_or_array if DataTable == table_or_array.class
495
521
  DataTable.from(table_or_array)
496
522
  end
497
523
 
@@ -507,7 +533,8 @@ module Cucumber
507
533
  attr_reader :exception
508
534
 
509
535
  def initialize(table, cells)
510
- @table, @cells = table, cells
536
+ @table = table
537
+ @cells = cells
511
538
  end
512
539
 
513
540
  def accept(visitor)
@@ -563,19 +590,21 @@ module Cucumber
563
590
  attr_accessor :status, :value
564
591
 
565
592
  def initialize(value, table, line)
566
- @value, @table, @line = value, table, line
593
+ @value = value
594
+ @table = table
595
+ @line = line
567
596
  end
568
597
 
569
598
  def inspect!
570
599
  @value = "(i) #{value.inspect}"
571
600
  end
572
601
 
573
- def ==(o)
574
- SurplusCell === o || value == o.value
602
+ def ==(other)
603
+ SurplusCell == other.class || value == other.value
575
604
  end
576
605
 
577
- def eql?(o)
578
- self == o
606
+ def eql?(other)
607
+ self == other
579
608
  end
580
609
 
581
610
  def hash
@@ -593,7 +622,7 @@ module Cucumber
593
622
  :comment
594
623
  end
595
624
 
596
- def ==(_o)
625
+ def ==(_other)
597
626
  true
598
627
  end
599
628
 
@@ -135,7 +135,7 @@ module Cucumber
135
135
  def raise_error
136
136
  table = DataTable.from([[]])
137
137
  table.instance_variable_set :@cell_matrix, cell_matrix
138
- raise Different.new(table) if should_raise?
138
+ raise Different, table if should_raise?
139
139
  end
140
140
 
141
141
  def should_raise?
@@ -4,7 +4,7 @@ module Cucumber
4
4
  module MultilineArgument
5
5
  class DocString < SimpleDelegator
6
6
  def append_to(array)
7
- array << self.to_s
7
+ array << to_s
8
8
  end
9
9
  end
10
10
  end
@@ -7,7 +7,7 @@ require 'cucumber/core/platform'
7
7
 
8
8
  module Cucumber
9
9
  unless defined?(Cucumber::VERSION)
10
- VERSION = File.read(File.expand_path('../version', __FILE__))
10
+ VERSION = File.read(File.expand_path('version', __dir__))
11
11
  BINARY = File.expand_path(File.dirname(__FILE__) + '/../../bin/cucumber')
12
12
  LIBDIR = File.expand_path(File.dirname(__FILE__) + '/../../lib')
13
13
  RAILS = defined?(Rails)
@@ -18,8 +18,8 @@ module Cucumber
18
18
  attr_accessor :use_full_backtrace
19
19
 
20
20
  # @private
21
- def file_mode(m, encoding = 'UTF-8')
22
- "#{m}:#{encoding}"
21
+ def file_mode(mode, encoding = 'UTF-8')
22
+ "#{mode}:#{encoding}"
23
23
  end
24
24
  end
25
25
  self.use_full_backtrace = false
@@ -38,8 +38,8 @@ module Cucumber
38
38
  attr_reader :args
39
39
 
40
40
  def initialize(libs, cucumber_opts, feature_files)
41
- raise 'libs must be an Array when running in-process' unless Array === libs
42
- libs.reverse.each { |lib| $LOAD_PATH.unshift(lib) }
41
+ raise 'libs must be an Array when running in-process' unless Array == libs.class
42
+ libs.reverse_each { |lib| $LOAD_PATH.unshift(lib) }
43
43
  @args = (
44
44
  cucumber_opts +
45
45
  feature_files
@@ -65,11 +65,11 @@ module Cucumber
65
65
  end
66
66
 
67
67
  def load_path
68
- [format('"%s"', @libs.join(File::PATH_SEPARATOR))]
68
+ [format('"%<path>s"', path: @libs.join(File::PATH_SEPARATOR))]
69
69
  end
70
70
 
71
71
  def quoted_binary(cucumber_bin)
72
- [format('"%s"', cucumber_bin)]
72
+ [format('"%<path>s"', path: cucumber_bin)]
73
73
  end
74
74
 
75
75
  def use_bundler
@@ -98,9 +98,7 @@ module Cucumber
98
98
 
99
99
  def run
100
100
  sh cmd.join(' ') do |ok, res|
101
- if !ok
102
- exit res.exitstatus
103
- end
101
+ exit res.exitstatus unless ok
104
102
  end
105
103
  end
106
104
  end
@@ -113,9 +111,9 @@ module Cucumber
113
111
 
114
112
  # Extra options to pass to the cucumber binary. Can be overridden by the CUCUMBER_OPTS environment variable.
115
113
  # It's recommended to pass an Array, but if it's a String it will be #split by ' '.
116
- attr_accessor :cucumber_opts
114
+ attr_reader :cucumber_opts
117
115
  def cucumber_opts=(opts) #:nodoc:
118
- @cucumber_opts = String === opts ? opts.split(' ') : opts
116
+ @cucumber_opts = String == opts.class ? opts.split(' ') : opts
119
117
  end
120
118
 
121
119
  # Whether or not to fork a new ruby interpreter. Defaults to true. You may gain
@@ -136,10 +134,11 @@ module Cucumber
136
134
 
137
135
  # Define Cucumber Rake task
138
136
  def initialize(task_name = 'cucumber', desc = 'Run Cucumber features')
139
- @task_name, @desc = task_name, desc
137
+ @task_name = task_name
138
+ @desc = desc
140
139
  @fork = true
141
140
  @libs = ['lib']
142
- @rcov_opts = %w{--rails --exclude osx\/objc,gems\/}
141
+ @rcov_opts = %w[--rails --exclude osx\/objc,gems\/]
143
142
  yield self if block_given?
144
143
  @binary = binary.nil? ? Cucumber::BINARY : File.expand_path(binary)
145
144
  define_task
@@ -154,18 +153,16 @@ module Cucumber
154
153
 
155
154
  def runner(_task_args = nil) #:nodoc:
156
155
  cucumber_opts = [(ENV['CUCUMBER_OPTS'] ? ENV['CUCUMBER_OPTS'].split(/\s+/) : nil) || cucumber_opts_with_profile]
157
- if @fork
158
- return ForkedCucumberRunner.new(libs, binary, cucumber_opts, bundler, feature_files)
159
- end
156
+ return ForkedCucumberRunner.new(libs, binary, cucumber_opts, bundler, feature_files) if @fork
160
157
  InProcessCucumberRunner.new(libs, cucumber_opts, feature_files)
161
158
  end
162
159
 
163
160
  def cucumber_opts_with_profile #:nodoc:
164
- Array(cucumber_opts).concat Array(@profile).flat_map { |p| ['--profile', p] }
161
+ Array(cucumber_opts).concat(Array(@profile).flat_map { |p| ['--profile', p] })
165
162
  end
166
163
 
167
164
  def feature_files #:nodoc:
168
- make_command_line_safe(FileList[ ENV['FEATURE'] || [] ])
165
+ make_command_line_safe(FileList[ENV['FEATURE'] || []])
169
166
  end
170
167
 
171
168
  def make_command_line_safe(list)