cucumber 4.0.0.rc.3 → 4.0.0.rc.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +17 -1
  3. data/lib/cucumber/cli/options.rb +2 -1
  4. data/lib/cucumber/configuration.rb +5 -0
  5. data/lib/cucumber/deprecate.rb +29 -5
  6. data/lib/cucumber/errors.rb +3 -0
  7. data/lib/cucumber/events.rb +12 -7
  8. data/lib/cucumber/events/envelope.rb +9 -0
  9. data/lib/cucumber/events/hook_test_step_created.rb +13 -0
  10. data/lib/cucumber/events/test_case_created.rb +13 -0
  11. data/lib/cucumber/events/test_case_ready.rb +12 -0
  12. data/lib/cucumber/events/test_step_created.rb +13 -0
  13. data/lib/cucumber/filters.rb +1 -0
  14. data/lib/cucumber/filters/broadcast_test_case_ready_event.rb +12 -0
  15. data/lib/cucumber/formatter/console.rb +3 -8
  16. data/lib/cucumber/formatter/duration_extractor.rb +1 -1
  17. data/lib/cucumber/formatter/errors.rb +6 -0
  18. data/lib/cucumber/formatter/json.rb +15 -6
  19. data/lib/cucumber/formatter/junit.rb +1 -1
  20. data/lib/cucumber/formatter/message.rb +246 -0
  21. data/lib/cucumber/formatter/pretty.rb +3 -4
  22. data/lib/cucumber/formatter/query/hook_by_test_step.rb +31 -0
  23. data/lib/cucumber/formatter/query/pickle_by_test.rb +26 -0
  24. data/lib/cucumber/formatter/query/pickle_step_by_test_step.rb +26 -0
  25. data/lib/cucumber/formatter/query/step_definitions_by_test_step.rb +40 -0
  26. data/lib/cucumber/formatter/query/test_case_started_by_test_case.rb +40 -0
  27. data/lib/cucumber/gherkin/data_table_parser.rb +1 -1
  28. data/lib/cucumber/gherkin/steps_parser.rb +1 -1
  29. data/lib/cucumber/glue/hook.rb +18 -2
  30. data/lib/cucumber/glue/proto_world.rb +30 -18
  31. data/lib/cucumber/glue/registry_and_more.rb +31 -2
  32. data/lib/cucumber/glue/step_definition.rb +28 -4
  33. data/lib/cucumber/hooks.rb +8 -8
  34. data/lib/cucumber/multiline_argument.rb +1 -1
  35. data/lib/cucumber/multiline_argument/data_table.rb +17 -13
  36. data/lib/cucumber/runtime.rb +2 -2
  37. data/lib/cucumber/runtime/after_hooks.rb +6 -2
  38. data/lib/cucumber/runtime/before_hooks.rb +6 -2
  39. data/lib/cucumber/runtime/for_programming_languages.rb +1 -0
  40. data/lib/cucumber/runtime/step_hooks.rb +3 -2
  41. data/lib/cucumber/runtime/support_code.rb +3 -3
  42. data/lib/cucumber/runtime/user_interface.rb +2 -10
  43. data/lib/cucumber/version +1 -1
  44. metadata +40 -27
@@ -15,7 +15,7 @@ module Cucumber
15
15
  location ||= Core::Test::Location.of_caller
16
16
  case argument
17
17
  when String
18
- builder.doc_string(Core::Test::DocString.new(argument, content_type, location))
18
+ builder.doc_string(Core::Test::DocString.new(argument, content_type))
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)
@@ -36,12 +36,12 @@ module Cucumber
36
36
  end
37
37
 
38
38
  class << self
39
- def from(data, location = Core::Test::Location.of_caller)
39
+ def from(data)
40
40
  case data
41
41
  when Array
42
- from_array(data, location)
42
+ from_array(data)
43
43
  when String
44
- parse(data, location)
44
+ parse(data)
45
45
  else
46
46
  raise ArgumentError, 'expected data to be a String or an Array.'
47
47
  end
@@ -49,15 +49,15 @@ module Cucumber
49
49
 
50
50
  private
51
51
 
52
- def parse(text, location = Core::Test::Location.of_caller)
52
+ def parse(text)
53
53
  builder = Builder.new
54
54
  parser = Cucumber::Gherkin::DataTableParser.new(builder)
55
55
  parser.parse(text)
56
- from_array(builder.rows, location)
56
+ from_array(builder.rows)
57
57
  end
58
58
 
59
- def from_array(data, location = Core::Test::Location.of_caller)
60
- new Core::Test::DataTable.new(data, location)
59
+ def from_array(data)
60
+ new Core::Test::DataTable.new(data)
61
61
  end
62
62
  end
63
63
 
@@ -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::Test::DataTable.new(raw, location), @conversion_procs.dup, @header_mappings.dup, @header_conversion_proc)
114
+ self.class.new(Core::Test::DataTable.new(raw), @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::Test::DataTable.new(raw.transpose, location), @conversion_procs.dup, @header_mappings.dup, @header_conversion_proc)
129
+ self.class.new(Core::Test::DataTable.new(raw.transpose), @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
@@ -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::Test::DataTable.new(raw, location), @conversion_procs.dup, mappings, block)
272
+ self.class.new(Core::Test::DataTable.new(raw), @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
@@ -294,7 +294,7 @@ module Cucumber
294
294
  def map_column(column_name, strict = true, &conversion_proc)
295
295
  conversion_procs = @conversion_procs.dup
296
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)
297
+ self.class.new(Core::Test::DataTable.new(raw), 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
@@ -352,7 +352,11 @@ module Cucumber
352
352
  end
353
353
  end
354
354
 
355
- def to_hash(cells) #:nodoc:
355
+ def to_hash
356
+ cells_rows.map { |cells| cells.map(&:value) }
357
+ end
358
+
359
+ def cells_to_hash(cells) #:nodoc:
356
360
  hash = Hash.new do |hash_inner, key|
357
361
  hash_inner[key.to_s] if key.is_a?(Symbol)
358
362
  end
@@ -551,7 +555,7 @@ module Cucumber
551
555
  end
552
556
 
553
557
  def to_hash #:nodoc:
554
- @to_hash ||= @table.to_hash(self)
558
+ @to_hash ||= @table.cells_to_hash(self)
555
559
  end
556
560
 
557
561
  def value(n) #:nodoc:
@@ -97,8 +97,7 @@ module Cucumber
97
97
  # Returns Ast::DocString for +string_without_triple_quotes+.
98
98
  #
99
99
  def doc_string(string_without_triple_quotes, content_type = '', _line_offset = 0)
100
- location = Core::Test::Location.of_caller
101
- Core::Test::DocString.new(string_without_triple_quotes, content_type, location)
100
+ Core::Test::DocString.new(string_without_triple_quotes, content_type)
102
101
  end
103
102
 
104
103
  private
@@ -228,6 +227,7 @@ module Cucumber
228
227
  filters << Filters::ApplyBeforeHooks.new(@support_code)
229
228
  filters << Filters::ApplyAfterHooks.new(@support_code)
230
229
  filters << Filters::ApplyAroundHooks.new(@support_code)
230
+ filters << Filters::BroadcastTestCaseReadyEvent.new(@configuration)
231
231
  filters << Filters::BroadcastTestRunStartedEvent.new(@configuration)
232
232
  filters << Filters::Quit.new
233
233
  filters << Filters::Retry.new(@configuration)
@@ -3,9 +3,11 @@
3
3
  module Cucumber
4
4
  class Runtime
5
5
  class AfterHooks
6
- def initialize(hooks, scenario)
6
+ def initialize(id_generator, hooks, scenario, event_bus)
7
7
  @hooks = hooks
8
8
  @scenario = scenario
9
+ @id_generator = id_generator
10
+ @event_bus = event_bus
9
11
  end
10
12
 
11
13
  def apply_to(test_case)
@@ -19,7 +21,9 @@ module Cucumber
19
21
  def after_hooks
20
22
  @hooks.map do |hook|
21
23
  action = ->(result) { hook.invoke('After', @scenario.with_result(result)) }
22
- Hooks.after_hook(hook.location, &action)
24
+ hook_step = Hooks.after_hook(@id_generator.new_id, hook.location, &action)
25
+ @event_bus.hook_test_step_created(hook_step, hook)
26
+ hook_step
23
27
  end
24
28
  end
25
29
  end
@@ -5,9 +5,11 @@ require 'cucumber/hooks'
5
5
  module Cucumber
6
6
  class Runtime
7
7
  class BeforeHooks
8
- def initialize(hooks, scenario)
8
+ def initialize(id_generator, hooks, scenario, event_bus)
9
9
  @hooks = hooks
10
10
  @scenario = scenario
11
+ @id_generator = id_generator
12
+ @event_bus = event_bus
11
13
  end
12
14
 
13
15
  def apply_to(test_case)
@@ -21,7 +23,9 @@ module Cucumber
21
23
  def before_hooks
22
24
  @hooks.map do |hook|
23
25
  action_block = ->(result) { hook.invoke('Before', @scenario.with_result(result)) }
24
- Hooks.before_hook(hook.location, &action_block)
26
+ hook_step = Hooks.before_hook(@id_generator.new_id, hook.location, &action_block)
27
+ @event_bus.hook_test_step_created(hook_step, hook)
28
+ hook_step
25
29
  end
26
30
  end
27
31
  end
@@ -21,6 +21,7 @@ module Cucumber
21
21
 
22
22
  def_delegators :@user_interface,
23
23
  :embed,
24
+ :attach,
24
25
  :ask,
25
26
  :puts,
26
27
  :features_paths,
@@ -3,8 +3,9 @@
3
3
  module Cucumber
4
4
  class Runtime
5
5
  class StepHooks
6
- def initialize(hooks)
6
+ def initialize(id_generator, hooks)
7
7
  @hooks = hooks
8
+ @id_generator = id_generator
8
9
  end
9
10
 
10
11
  def apply(test_steps)
@@ -18,7 +19,7 @@ module Cucumber
18
19
  def after_step_hooks(test_step)
19
20
  @hooks.map do |hook|
20
21
  action = ->(*args) { hook.invoke('AfterStep', [args, test_step]) }
21
- Hooks.after_step_hook(test_step, hook.location, &action)
22
+ Hooks.after_step_hook(@id_generator.new_id, test_step, hook.location, &action)
22
23
  end
23
24
  end
24
25
  end
@@ -104,21 +104,21 @@ module Cucumber
104
104
  def find_after_step_hooks(test_case)
105
105
  scenario = RunningTestCase.new(test_case)
106
106
  hooks = registry.hooks_for(:after_step, scenario)
107
- StepHooks.new hooks
107
+ StepHooks.new(@configuration.id_generator, hooks)
108
108
  end
109
109
 
110
110
  def apply_before_hooks(test_case)
111
111
  return test_case if test_case.test_steps.empty?
112
112
  scenario = RunningTestCase.new(test_case)
113
113
  hooks = registry.hooks_for(:before, scenario)
114
- BeforeHooks.new(hooks, scenario).apply_to(test_case)
114
+ BeforeHooks.new(@configuration.id_generator, hooks, scenario, @configuration.event_bus).apply_to(test_case)
115
115
  end
116
116
 
117
117
  def apply_after_hooks(test_case)
118
118
  return test_case if test_case.test_steps.empty?
119
119
  scenario = RunningTestCase.new(test_case)
120
120
  hooks = registry.hooks_for(:after, scenario)
121
- AfterHooks.new(hooks, scenario).apply_to(test_case)
121
+ AfterHooks.new(@configuration.id_generator, hooks, scenario, @configuration.event_bus).apply_to(test_case)
122
122
  end
123
123
 
124
124
  def find_around_hooks(test_case)
@@ -7,14 +7,6 @@ module Cucumber
7
7
  module UserInterface
8
8
  attr_writer :visitor
9
9
 
10
- # Output +messages+ alongside the formatted output.
11
- # This is an alternative to using Kernel#puts - it will display
12
- # nicer, and in all outputs (in case you use several formatters)
13
- #
14
- def puts(*messages)
15
- @visitor.puts(*messages)
16
- end
17
-
18
10
  # Suspends execution and prompts +question+ to the console (STDOUT).
19
11
  # An operator (manual tester) can then enter a line of text and hit
20
12
  # <ENTER>. The entered text is returned, and both +question+ and
@@ -48,8 +40,8 @@ module Cucumber
48
40
  # be a path to a file, or if it's an image it may also be a Base64 encoded image.
49
41
  # The embedded data may or may not be ignored, depending on what kind of formatter(s) are active.
50
42
  #
51
- def embed(src, mime_type, label)
52
- @visitor.embed(src, mime_type, label)
43
+ def attach(src, media_type)
44
+ @visitor.attach(src, media_type)
53
45
  end
54
46
 
55
47
  private
@@ -1 +1 @@
1
- 4.0.0.rc.3
1
+ 4.0.0.rc.4
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.rc.3
4
+ version: 4.0.0.rc.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aslak Hellesøy
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-10-31 00:00:00.000000000 Z
13
+ date: 2020-02-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: builder
@@ -38,20 +38,20 @@ dependencies:
38
38
  requirements:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: 5.0.0
41
+ version: 6.0.0
42
42
  - - "~>"
43
43
  - !ruby/object:Gem::Version
44
- version: '5.0'
44
+ version: '6.0'
45
45
  type: :runtime
46
46
  prerelease: false
47
47
  version_requirements: !ruby/object:Gem::Requirement
48
48
  requirements:
49
49
  - - ">="
50
50
  - !ruby/object:Gem::Version
51
- version: 5.0.0
51
+ version: 6.0.0
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '5.0'
54
+ version: '6.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: cucumber-expressions
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -73,65 +73,65 @@ dependencies:
73
73
  - !ruby/object:Gem::Version
74
74
  version: 8.0.2
75
75
  - !ruby/object:Gem::Dependency
76
- name: cucumber-wire
76
+ name: cucumber-gherkin
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - ">="
80
80
  - !ruby/object:Gem::Version
81
- version: 1.1.0
81
+ version: 10.0.0
82
82
  - - "~>"
83
83
  - !ruby/object:Gem::Version
84
- version: '1.1'
84
+ version: '10.0'
85
85
  type: :runtime
86
86
  prerelease: false
87
87
  version_requirements: !ruby/object:Gem::Requirement
88
88
  requirements:
89
89
  - - ">="
90
90
  - !ruby/object:Gem::Version
91
- version: 1.1.0
91
+ version: 10.0.0
92
92
  - - "~>"
93
93
  - !ruby/object:Gem::Version
94
- version: '1.1'
94
+ version: '10.0'
95
95
  - !ruby/object:Gem::Dependency
96
- name: diff-lcs
96
+ name: cucumber-wire
97
97
  requirement: !ruby/object:Gem::Requirement
98
98
  requirements:
99
99
  - - ">="
100
100
  - !ruby/object:Gem::Version
101
- version: '1.3'
101
+ version: 2.0.0
102
102
  - - "~>"
103
103
  - !ruby/object:Gem::Version
104
- version: '1.3'
104
+ version: '2.0'
105
105
  type: :runtime
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - ">="
110
110
  - !ruby/object:Gem::Version
111
- version: '1.3'
111
+ version: 2.0.0
112
112
  - - "~>"
113
113
  - !ruby/object:Gem::Version
114
- version: '1.3'
114
+ version: '2.0'
115
115
  - !ruby/object:Gem::Dependency
116
- name: gherkin
116
+ name: diff-lcs
117
117
  requirement: !ruby/object:Gem::Requirement
118
118
  requirements:
119
- - - "~>"
120
- - !ruby/object:Gem::Version
121
- version: '8.1'
122
119
  - - ">="
123
120
  - !ruby/object:Gem::Version
124
- version: 8.1.1
121
+ version: '1.3'
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.3'
125
125
  type: :runtime
126
126
  prerelease: false
127
127
  version_requirements: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '8.1'
132
129
  - - ">="
133
130
  - !ruby/object:Gem::Version
134
- version: 8.1.1
131
+ version: '1.3'
132
+ - - "~>"
133
+ - !ruby/object:Gem::Version
134
+ version: '1.3'
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: multi_json
137
137
  requirement: !ruby/object:Gem::Requirement
@@ -479,14 +479,19 @@ files:
479
479
  - lib/cucumber/encoding.rb
480
480
  - lib/cucumber/errors.rb
481
481
  - lib/cucumber/events.rb
482
+ - lib/cucumber/events/envelope.rb
482
483
  - lib/cucumber/events/gherkin_source_parsed.rb
483
484
  - lib/cucumber/events/gherkin_source_read.rb
485
+ - lib/cucumber/events/hook_test_step_created.rb
484
486
  - lib/cucumber/events/step_activated.rb
485
487
  - lib/cucumber/events/step_definition_registered.rb
488
+ - lib/cucumber/events/test_case_created.rb
486
489
  - lib/cucumber/events/test_case_finished.rb
490
+ - lib/cucumber/events/test_case_ready.rb
487
491
  - lib/cucumber/events/test_case_started.rb
488
492
  - lib/cucumber/events/test_run_finished.rb
489
493
  - lib/cucumber/events/test_run_started.rb
494
+ - lib/cucumber/events/test_step_created.rb
490
495
  - lib/cucumber/events/test_step_finished.rb
491
496
  - lib/cucumber/events/test_step_started.rb
492
497
  - lib/cucumber/file_specs.rb
@@ -496,6 +501,7 @@ files:
496
501
  - lib/cucumber/filters/apply_after_step_hooks.rb
497
502
  - lib/cucumber/filters/apply_around_hooks.rb
498
503
  - lib/cucumber/filters/apply_before_hooks.rb
504
+ - lib/cucumber/filters/broadcast_test_case_ready_event.rb
499
505
  - lib/cucumber/filters/broadcast_test_run_started_event.rb
500
506
  - lib/cucumber/filters/gated_receiver.rb
501
507
  - lib/cucumber/filters/prepare_world.rb
@@ -513,6 +519,7 @@ files:
513
519
  - lib/cucumber/formatter/console_issues.rb
514
520
  - lib/cucumber/formatter/duration.rb
515
521
  - lib/cucumber/formatter/duration_extractor.rb
522
+ - lib/cucumber/formatter/errors.rb
516
523
  - lib/cucumber/formatter/fail_fast.rb
517
524
  - lib/cucumber/formatter/fanout.rb
518
525
  - lib/cucumber/formatter/ignore_missing_messages.rb
@@ -520,8 +527,14 @@ files:
520
527
  - lib/cucumber/formatter/io.rb
521
528
  - lib/cucumber/formatter/json.rb
522
529
  - lib/cucumber/formatter/junit.rb
530
+ - lib/cucumber/formatter/message.rb
523
531
  - lib/cucumber/formatter/pretty.rb
524
532
  - lib/cucumber/formatter/progress.rb
533
+ - lib/cucumber/formatter/query/hook_by_test_step.rb
534
+ - lib/cucumber/formatter/query/pickle_by_test.rb
535
+ - lib/cucumber/formatter/query/pickle_step_by_test_step.rb
536
+ - lib/cucumber/formatter/query/step_definitions_by_test_step.rb
537
+ - lib/cucumber/formatter/query/test_case_started_by_test_case.rb
525
538
  - lib/cucumber/formatter/rerun.rb
526
539
  - lib/cucumber/formatter/stepdefs.rb
527
540
  - lib/cucumber/formatter/steps.rb
@@ -593,8 +606,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
593
606
  - !ruby/object:Gem::Version
594
607
  version: 1.3.1
595
608
  requirements: []
596
- rubygems_version: 3.0.3
609
+ rubygems_version: 3.0.6
597
610
  signing_key:
598
611
  specification_version: 4
599
- summary: cucumber-4.0.0.rc.3
612
+ summary: cucumber-4.0.0.rc.4
600
613
  test_files: []