cucumber 2.99.0 → 3.0.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +22 -10
  3. data/CONTRIBUTING.md +13 -0
  4. data/Gemfile +11 -4
  5. data/History.md +19 -1
  6. data/README.md +1 -1
  7. data/cucumber.gemspec +2 -2
  8. data/cucumber.yml +2 -2
  9. data/features/docs/api/listen_for_events.feature +7 -6
  10. data/features/docs/cli/help.feature +8 -0
  11. data/features/docs/cli/retry_failing_tests.feature +51 -16
  12. data/features/docs/defining_steps/nested_steps_i18n.feature +2 -0
  13. data/features/docs/defining_steps/printing_messages.feature +0 -1
  14. data/features/docs/defining_steps/skip_scenario.feature +0 -34
  15. data/features/docs/extending_cucumber/custom_formatter.feature +2 -30
  16. data/features/docs/formatters/summary_formatter.feature +34 -0
  17. data/features/docs/gherkin/unicode_table.feature +1 -1
  18. data/features/docs/post_configuration_hook.feature +0 -16
  19. data/features/docs/writing_support_code/world.feature +129 -0
  20. data/features/lib/step_definitions/aruba_steps.rb +1 -0
  21. data/features/lib/step_definitions/cli_steps.rb +4 -0
  22. data/features/lib/step_definitions/cucumber_steps.rb +1 -0
  23. data/features/lib/step_definitions/iso-8859-1_steps.rb +1 -0
  24. data/features/lib/step_definitions/json_steps.rb +1 -0
  25. data/features/lib/step_definitions/junit_steps.rb +1 -0
  26. data/features/lib/step_definitions/language_steps.rb +1 -0
  27. data/features/lib/step_definitions/profile_steps.rb +1 -0
  28. data/features/lib/step_definitions/retry_steps.rb +32 -12
  29. data/features/lib/step_definitions/ruby_steps.rb +1 -0
  30. data/features/lib/step_definitions/wire_steps.rb +1 -0
  31. data/features/lib/support/env.rb +2 -1
  32. data/features/lib/support/fake_wire_server.rb +1 -0
  33. data/features/lib/support/feature_factory.rb +1 -0
  34. data/features/lib/support/normalise_output.rb +1 -0
  35. data/gem_tasks/contributors.rake +1 -0
  36. data/gem_tasks/cov.rake +1 -0
  37. data/gem_tasks/cucumber.rake +1 -0
  38. data/gem_tasks/downloads.rb +1 -0
  39. data/gem_tasks/environment.rake +1 -0
  40. data/gem_tasks/examples.rake +2 -1
  41. data/gem_tasks/fix_cr_lf.rake +2 -1
  42. data/gem_tasks/flog.rake +2 -1
  43. data/gem_tasks/rspec.rake +1 -0
  44. data/gem_tasks/sass.rake +2 -1
  45. data/lib/autotest/cucumber.rb +1 -0
  46. data/lib/autotest/cucumber_mixin.rb +1 -0
  47. data/lib/autotest/cucumber_rails.rb +1 -0
  48. data/lib/autotest/cucumber_rails_rspec.rb +1 -0
  49. data/lib/autotest/cucumber_rails_rspec2.rb +1 -0
  50. data/lib/autotest/cucumber_rspec.rb +1 -0
  51. data/lib/autotest/cucumber_rspec2.rb +1 -0
  52. data/lib/autotest/discover.rb +1 -0
  53. data/lib/cucumber.rb +1 -13
  54. data/lib/cucumber/cli/configuration.rb +3 -6
  55. data/lib/cucumber/cli/main.rb +2 -1
  56. data/lib/cucumber/cli/options.rb +239 -173
  57. data/lib/cucumber/cli/profile_loader.rb +1 -0
  58. data/lib/cucumber/cli/rerun_file.rb +1 -0
  59. data/lib/cucumber/configuration.rb +40 -19
  60. data/lib/cucumber/constantize.rb +1 -0
  61. data/lib/cucumber/core_ext/instance_exec.rb +1 -0
  62. data/lib/cucumber/core_ext/string.rb +1 -0
  63. data/lib/cucumber/deprecate.rb +1 -0
  64. data/lib/cucumber/encoding.rb +1 -0
  65. data/lib/cucumber/errors.rb +3 -1
  66. data/lib/cucumber/events.rb +13 -3
  67. data/lib/cucumber/events/step_definition_registered.rb +24 -0
  68. data/lib/cucumber/events/step_match.rb +4 -1
  69. data/lib/cucumber/events/test_run_finished.rb +12 -0
  70. data/lib/cucumber/file_specs.rb +1 -0
  71. data/lib/cucumber/filters.rb +2 -0
  72. data/lib/cucumber/filters/activate_steps.rb +2 -1
  73. data/lib/cucumber/filters/apply_after_hooks.rb +1 -0
  74. data/lib/cucumber/filters/apply_after_step_hooks.rb +1 -0
  75. data/lib/cucumber/filters/apply_around_hooks.rb +1 -0
  76. data/lib/cucumber/filters/apply_before_hooks.rb +1 -0
  77. data/lib/cucumber/filters/gated_receiver.rb +1 -0
  78. data/lib/cucumber/filters/prepare_world.rb +1 -0
  79. data/lib/cucumber/filters/quit.rb +1 -0
  80. data/lib/cucumber/filters/randomizer.rb +1 -0
  81. data/lib/cucumber/filters/retry.rb +3 -3
  82. data/lib/cucumber/filters/tag_limits.rb +1 -0
  83. data/lib/cucumber/filters/tag_limits/test_case_index.rb +1 -0
  84. data/lib/cucumber/filters/tag_limits/verifier.rb +1 -0
  85. data/lib/cucumber/formatter/ansicolor.rb +1 -0
  86. data/lib/cucumber/formatter/backtrace_filter.rb +3 -2
  87. data/lib/cucumber/formatter/console.rb +61 -52
  88. data/lib/cucumber/formatter/console_counts.rb +57 -0
  89. data/lib/cucumber/formatter/console_issues.rb +37 -0
  90. data/lib/cucumber/formatter/debug.rb +1 -0
  91. data/lib/cucumber/formatter/duration.rb +1 -0
  92. data/lib/cucumber/formatter/duration_extractor.rb +1 -0
  93. data/lib/cucumber/formatter/fail_fast.rb +4 -2
  94. data/lib/cucumber/formatter/fanout.rb +1 -0
  95. data/lib/cucumber/formatter/hook_query_visitor.rb +1 -0
  96. data/lib/cucumber/formatter/html.rb +6 -5
  97. data/lib/cucumber/formatter/ignore_missing_messages.rb +1 -0
  98. data/lib/cucumber/formatter/interceptor.rb +1 -0
  99. data/lib/cucumber/formatter/io.rb +1 -0
  100. data/lib/cucumber/formatter/json.rb +15 -13
  101. data/lib/cucumber/formatter/json_pretty.rb +1 -0
  102. data/lib/cucumber/formatter/junit.rb +13 -11
  103. data/lib/cucumber/formatter/legacy_api/adapter.rb +28 -32
  104. data/lib/cucumber/formatter/legacy_api/ast.rb +1 -0
  105. data/lib/cucumber/formatter/legacy_api/results.rb +1 -0
  106. data/lib/cucumber/formatter/legacy_api/runtime_facade.rb +1 -0
  107. data/lib/cucumber/formatter/pretty.rb +7 -1
  108. data/lib/cucumber/formatter/progress.rb +56 -13
  109. data/lib/cucumber/formatter/rerun.rb +15 -18
  110. data/lib/cucumber/formatter/stepdefs.rb +1 -0
  111. data/lib/cucumber/formatter/steps.rb +1 -0
  112. data/lib/cucumber/formatter/summary.rb +43 -20
  113. data/lib/cucumber/formatter/unicode.rb +1 -0
  114. data/lib/cucumber/formatter/usage.rb +26 -21
  115. data/lib/cucumber/gherkin/data_table_parser.rb +1 -0
  116. data/lib/cucumber/gherkin/formatter/ansi_escapes.rb +1 -0
  117. data/lib/cucumber/gherkin/formatter/escaping.rb +1 -0
  118. data/lib/cucumber/gherkin/i18n.rb +1 -0
  119. data/lib/cucumber/gherkin/steps_parser.rb +1 -0
  120. data/lib/cucumber/hooks.rb +1 -0
  121. data/lib/cucumber/load_path.rb +1 -0
  122. data/lib/cucumber/multiline_argument.rb +1 -2
  123. data/lib/cucumber/multiline_argument/data_table.rb +3 -1
  124. data/lib/cucumber/multiline_argument/doc_string.rb +1 -0
  125. data/lib/cucumber/platform.rb +1 -0
  126. data/lib/cucumber/project_initializer.rb +2 -1
  127. data/lib/cucumber/rake/task.rb +1 -0
  128. data/lib/cucumber/rb_support/rb_dsl.rb +11 -9
  129. data/lib/cucumber/rb_support/rb_hook.rb +1 -0
  130. data/lib/cucumber/rb_support/rb_language.rb +19 -8
  131. data/lib/cucumber/rb_support/rb_step_definition.rb +1 -0
  132. data/lib/cucumber/rb_support/rb_transform.rb +1 -0
  133. data/lib/cucumber/rb_support/rb_world.rb +42 -20
  134. data/lib/cucumber/rb_support/snippet.rb +2 -1
  135. data/lib/cucumber/rspec/disable_option_parser.rb +1 -0
  136. data/lib/cucumber/rspec/doubles.rb +1 -0
  137. data/lib/cucumber/running_test_case.rb +1 -25
  138. data/lib/cucumber/runtime.rb +15 -10
  139. data/lib/cucumber/runtime/after_hooks.rb +1 -0
  140. data/lib/cucumber/runtime/before_hooks.rb +1 -0
  141. data/lib/cucumber/runtime/for_programming_languages.rb +1 -0
  142. data/lib/cucumber/runtime/step_hooks.rb +1 -0
  143. data/lib/cucumber/runtime/support_code.rb +1 -0
  144. data/lib/cucumber/runtime/user_interface.rb +1 -0
  145. data/lib/cucumber/step_argument.rb +1 -0
  146. data/lib/cucumber/step_definition_light.rb +1 -0
  147. data/lib/cucumber/step_definitions.rb +1 -0
  148. data/lib/cucumber/step_match.rb +1 -0
  149. data/lib/cucumber/step_match_search.rb +1 -0
  150. data/lib/cucumber/term/ansicolor.rb +1 -0
  151. data/lib/cucumber/unit.rb +1 -0
  152. data/lib/cucumber/version +1 -1
  153. data/lib/simplecov_setup.rb +1 -0
  154. data/spec/cucumber/cli/configuration_spec.rb +1 -0
  155. data/spec/cucumber/cli/main_spec.rb +1 -0
  156. data/spec/cucumber/cli/options_spec.rb +1 -0
  157. data/spec/cucumber/cli/profile_loader_spec.rb +1 -0
  158. data/spec/cucumber/cli/rerun_spec.rb +1 -0
  159. data/spec/cucumber/configuration_spec.rb +1 -0
  160. data/spec/cucumber/constantize_spec.rb +1 -0
  161. data/spec/cucumber/core_ext/instance_exec_spec.rb +1 -0
  162. data/spec/cucumber/file_specs_spec.rb +1 -0
  163. data/spec/cucumber/filters/activate_steps_spec.rb +9 -6
  164. data/spec/cucumber/filters/gated_receiver_spec.rb +1 -0
  165. data/spec/cucumber/filters/retry_spec.rb +27 -21
  166. data/spec/cucumber/filters/tag_limits/test_case_index_spec.rb +1 -0
  167. data/spec/cucumber/filters/tag_limits/verifier_spec.rb +1 -0
  168. data/spec/cucumber/filters/tag_limits_spec.rb +1 -0
  169. data/spec/cucumber/formatter/ansicolor_spec.rb +1 -0
  170. data/spec/cucumber/formatter/console_counts_spec.rb +14 -0
  171. data/spec/cucumber/formatter/debug_spec.rb +1 -0
  172. data/spec/cucumber/formatter/duration_spec.rb +1 -0
  173. data/spec/cucumber/formatter/fail_fast_spec.rb +5 -5
  174. data/spec/cucumber/formatter/html_spec.rb +6 -1
  175. data/spec/cucumber/formatter/interceptor_spec.rb +1 -0
  176. data/spec/cucumber/formatter/json_spec.rb +29 -28
  177. data/spec/cucumber/formatter/junit_spec.rb +1 -0
  178. data/spec/cucumber/formatter/legacy_api/adapter_spec.rb +8 -3
  179. data/spec/cucumber/formatter/pretty_spec.rb +1 -0
  180. data/spec/cucumber/formatter/progress_spec.rb +2 -1
  181. data/spec/cucumber/formatter/rerun_spec.rb +70 -64
  182. data/spec/cucumber/formatter/spec_helper.rb +8 -7
  183. data/spec/cucumber/hooks_spec.rb +1 -0
  184. data/spec/cucumber/multiline_argument/data_table_spec.rb +1 -0
  185. data/spec/cucumber/project_initializer_spec.rb +2 -1
  186. data/spec/cucumber/rake/forked_spec.rb +1 -0
  187. data/spec/cucumber/rake/task_spec.rb +1 -0
  188. data/spec/cucumber/rb_support/rb_language_spec.rb +81 -3
  189. data/spec/cucumber/rb_support/rb_step_definition_spec.rb +1 -0
  190. data/spec/cucumber/rb_support/rb_transform_spec.rb +1 -0
  191. data/spec/cucumber/rb_support/rb_world_spec.rb +2 -1
  192. data/spec/cucumber/rb_support/snippet_spec.rb +1 -0
  193. data/spec/cucumber/running_test_case_spec.rb +1 -0
  194. data/spec/cucumber/runtime/for_programming_languages_spec.rb +1 -0
  195. data/spec/cucumber/runtime/support_code_spec.rb +1 -0
  196. data/spec/cucumber/runtime_spec.rb +1 -0
  197. data/spec/cucumber/step_argument_spec.rb +1 -0
  198. data/spec/cucumber/step_match_search_spec.rb +1 -0
  199. data/spec/cucumber/step_match_spec.rb +1 -0
  200. data/spec/cucumber/world/pending_spec.rb +1 -0
  201. data/spec/spec_helper.rb +1 -0
  202. data/spec/support/standard_step_actions.rb +1 -0
  203. metadata +24 -23
  204. data/lib/cucumber/ast.rb +0 -13
  205. data/lib/cucumber/events/after_test_case.rb +0 -25
  206. data/lib/cucumber/events/after_test_step.rb +0 -30
  207. data/lib/cucumber/events/before_test_case.rb +0 -18
  208. data/lib/cucumber/events/before_test_step.rb +0 -23
  209. data/lib/cucumber/events/bus.rb +0 -86
  210. data/lib/cucumber/events/finished_testing.rb +0 -9
  211. data/lib/cucumber/formatter/event_bus_report.rb +0 -38
  212. data/spec/cucumber/events/bus_spec.rb +0 -94
  213. data/spec/cucumber/formatter/event_bus_report_spec.rb +0 -88
  214. data/spec/cucumber_spec.rb +0 -39
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
  require 'cucumber/formatter/spec_helper'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'cucumber/formatter/legacy_api/adapter'
2
3
  require 'cucumber/core'
3
4
  require 'cucumber/core/gherkin/writer'
@@ -13,9 +14,10 @@ module Cucumber
13
14
  include Core::Gherkin::Writer
14
15
  include Core
15
16
 
16
- let(:report) { Adapter.new(formatter, runtime.results, runtime.configuration) }
17
+ let!(:report) { Adapter.new(formatter, runtime.results, runtime.configuration) }
17
18
  let(:formatter) { double('formatter').as_null_object }
18
19
  let(:runtime) { Runtime.new }
20
+ let(:events) { runtime.configuration.event_bus }
19
21
  let(:step_match_search) { SimpleStepDefinitionSearch.new }
20
22
 
21
23
  Failure = Class.new(StandardError)
@@ -106,8 +108,9 @@ module Cucumber
106
108
  end
107
109
  end,
108
110
  ]
109
- runner = Core::Test::Runner.new(report)
111
+ runner = Core::Test::Runner.new(events)
110
112
  compile gherkin_docs, runner, default_filters
113
+ events.test_run_finished
111
114
  expect( formatter.legacy_messages ).to eq [
112
115
  :before_features,
113
116
  :before_feature,
@@ -2166,8 +2169,10 @@ module Cucumber
2166
2169
  end
2167
2170
 
2168
2171
  def execute_gherkin(filters = default_filters, &gherkin)
2169
- runner = Core::Test::Runner.new(report)
2172
+ runner = Core::Test::Runner.new(events)
2170
2173
  compile [gherkin(&gherkin)], runner, filters
2174
+ events.test_run_finished
2175
+ self
2171
2176
  end
2172
2177
 
2173
2178
  def default_filters
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
  require 'cucumber/formatter/spec_helper'
3
4
  require 'cucumber/formatter/pretty'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
  require 'cucumber/formatter/spec_helper'
3
4
  require 'cucumber/formatter/progress'
@@ -12,7 +13,7 @@ module Cucumber
12
13
  before(:each) do
13
14
  Cucumber::Term::ANSIColor.coloring = false
14
15
  @out = StringIO.new
15
- @formatter = Progress.new(runtime, @out, Cucumber::Cli::Options.new)
16
+ @formatter = Progress.new(actual_runtime.configuration.with_options(out_stream: @out))
16
17
  end
17
18
 
18
19
  describe "given a single feature" do
@@ -1,90 +1,96 @@
1
+ # frozen_string_literal: true
1
2
  require 'cucumber/formatter/rerun'
2
3
  require 'cucumber/core'
3
4
  require 'cucumber/core/gherkin/writer'
4
5
  require 'cucumber/core/filter'
5
6
  require 'support/standard_step_actions'
6
-
7
- module Cucumber::Formatter
8
- describe Rerun do
9
- include Cucumber::Core::Gherkin::Writer
10
- include Cucumber::Core
11
-
12
- # after_test_case
13
- context 'when 2 scenarios fail in the same file' do
14
- it 'Prints the locations of the failed scenarios' do
15
- gherkin = gherkin('foo.feature') do
16
- feature do
17
- scenario do
18
- step 'failing'
19
- end
20
-
21
- scenario do
22
- step 'failing'
23
- end
24
-
25
- scenario do
26
- step 'passing'
7
+ require 'cucumber/configuration'
8
+
9
+ module Cucumber
10
+ module Formatter
11
+ describe Rerun do
12
+ include Cucumber::Core::Gherkin::Writer
13
+ include Cucumber::Core
14
+
15
+ let(:config) { Cucumber::Configuration.new(out_stream: io) }
16
+ let(:io) { StringIO.new }
17
+
18
+ # after_test_case
19
+ context 'when 2 scenarios fail in the same file' do
20
+ it 'Prints the locations of the failed scenarios' do
21
+ gherkin = gherkin('foo.feature') do
22
+ feature do
23
+ scenario do
24
+ step 'failing'
25
+ end
26
+
27
+ scenario do
28
+ step 'failing'
29
+ end
30
+
31
+ scenario do
32
+ step 'passing'
33
+ end
27
34
  end
28
35
  end
29
- end
30
- io = StringIO.new
31
- report = Rerun.new(double, io, {})
32
-
33
- execute [gherkin], report, [StandardStepActions.new]
36
+ Rerun.new(config)
37
+ execute [gherkin], [StandardStepActions.new], config.event_bus
38
+ config.event_bus.test_run_finished
34
39
 
35
- expect( io.string ).to eq 'foo.feature:3:6'
40
+ expect( io.string ).to eq 'foo.feature:3:6'
41
+ end
36
42
  end
37
- end
38
43
 
39
- context 'with failures in multiple files' do
40
- it 'prints the location of the failed scenarios in each file' do
41
- foo = gherkin('foo.feature') do
42
- feature do
43
- scenario do
44
- step 'failing'
45
- end
46
-
47
- scenario do
48
- step 'failing'
49
- end
50
-
51
- scenario do
52
- step 'passing'
44
+ context 'with failures in multiple files' do
45
+ it 'prints the location of the failed scenarios in each file' do
46
+ foo = gherkin('foo.feature') do
47
+ feature do
48
+ scenario do
49
+ step 'failing'
50
+ end
51
+
52
+ scenario do
53
+ step 'failing'
54
+ end
55
+
56
+ scenario do
57
+ step 'passing'
58
+ end
53
59
  end
54
60
  end
55
- end
56
61
 
57
- bar = gherkin('bar.feature') do
58
- feature do
59
- scenario do
60
- step 'failing'
62
+ bar = gherkin('bar.feature') do
63
+ feature do
64
+ scenario do
65
+ step 'failing'
66
+ end
61
67
  end
62
68
  end
63
- end
64
69
 
65
- io = StringIO.new
66
- report = Rerun.new(double, io, {})
70
+ Rerun.new(config)
71
+ execute [foo, bar], [StandardStepActions.new], config.event_bus
72
+ config.event_bus.test_run_finished
67
73
 
68
- execute [foo, bar], report, [StandardStepActions.new]
69
-
70
- expect(io.string).to eq 'foo.feature:3:6 bar.feature:3'
74
+ expect(io.string).to eq 'foo.feature:3:6 bar.feature:3'
75
+ end
71
76
  end
72
- end
73
77
 
74
- context 'when there are no failing scenarios' do
75
- it 'prints nothing' do
76
- gherkin = gherkin('foo.feature') do
77
- feature do
78
- scenario do
79
- step 'passing'
78
+ context 'when there are no failing scenarios' do
79
+ it 'prints nothing' do
80
+ gherkin = gherkin('foo.feature') do
81
+ feature do
82
+ scenario do
83
+ step 'passing'
84
+ end
80
85
  end
81
86
  end
82
- end
83
87
 
84
- io = StringIO.new
85
- report = Rerun.new(double, io, {})
88
+ Rerun.new(config)
89
+ execute [gherkin], [StandardStepActions.new], config.event_bus
90
+ config.event_bus.test_run_finished
86
91
 
87
- execute [gherkin], report, [StandardStepActions.new]
92
+ expect(io.string).to eq ''
93
+ end
88
94
  end
89
95
  end
90
96
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Cucumber
2
3
  module Formatter
3
4
  module SpecHelperDsl
@@ -21,7 +22,7 @@ module Cucumber
21
22
  define_steps
22
23
  actual_runtime.visitor = report
23
24
 
24
- receiver = Test::Runner.new(report)
25
+ receiver = Test::Runner.new(event_bus)
25
26
  filters = [
26
27
  Filters::ActivateSteps.new(
27
28
  StepMatchSearch.new(actual_runtime.support_code.ruby.method(:step_matches), actual_runtime.configuration),
@@ -34,17 +35,13 @@ module Cucumber
34
35
  Filters::PrepareWorld.new(actual_runtime)
35
36
  ]
36
37
  compile [gherkin_doc], receiver, filters
37
- end
38
-
39
- require 'cucumber/formatter/event_bus_report'
40
- def event_bus_report
41
- @event_bus_report ||= Formatter::EventBusReport.new(actual_runtime.configuration)
38
+ event_bus.test_run_finished
42
39
  end
43
40
 
44
41
  require 'cucumber/formatter/legacy_api/adapter'
45
42
  def report
46
43
  @report ||= LegacyApi::Adapter.new(
47
- Fanout.new([@formatter, event_bus_report]),
44
+ Fanout.new([@formatter]),
48
45
  actual_runtime.results,
49
46
  actual_runtime.configuration)
50
47
  end
@@ -66,6 +63,10 @@ module Cucumber
66
63
  @runtime ||= Runtime.new(options)
67
64
  end
68
65
 
66
+ def event_bus
67
+ actual_runtime.configuration.event_bus
68
+ end
69
+
69
70
  def define_steps
70
71
  return unless step_defs = self.class.step_defs
71
72
  rb = runtime.support_code.ruby
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'cucumber/hooks'
2
3
  module Cucumber::Hooks
3
4
  shared_examples_for 'a source node' do
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  require 'spec_helper'
3
4
  require 'cucumber/multiline_argument/data_table'
4
5
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
  require 'tmpdir'
3
4
 
@@ -84,4 +85,4 @@ module Cucumber
84
85
 
85
86
  end
86
87
  end
87
- end
88
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
  require 'cucumber/rake/task'
3
4
  require 'rake'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
  require 'cucumber/rake/task'
3
4
  require 'rake'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
  require 'cucumber/rb_support/rb_language'
3
4
 
@@ -17,10 +18,11 @@ module Cucumber
17
18
  describe "#load_code_file" do
18
19
  after do
19
20
  FileUtils.rm_rf('tmp.rb')
21
+ FileUtils.rm_rf('docs.md')
20
22
  end
21
23
 
22
24
  def a_file_called(name)
23
- File.open('tmp.rb', 'w') do |f|
25
+ File.open(name, 'w') do |f|
24
26
  f.puts yield
25
27
  end
26
28
  end
@@ -43,10 +45,10 @@ module Cucumber
43
45
  end
44
46
 
45
47
  it "only loads ruby files" do
46
- a_file_called("readme.md") do
48
+ a_file_called("docs.md") do
47
49
  "yo"
48
50
  end
49
- rb.load_code_file('readme.md')
51
+ rb.load_code_file('docs.md')
50
52
  end
51
53
  end
52
54
 
@@ -104,6 +106,82 @@ or http://wiki.github.com/cucumber/cucumber/a-whole-new-world.
104
106
  end
105
107
  end
106
108
 
109
+ describe 'Handling namespaced World' do
110
+ module ModuleOne
111
+ def method_one
112
+ 1
113
+ end
114
+ end
115
+
116
+ module ModuleMinusOne
117
+ def method_one
118
+ -1
119
+ end
120
+ end
121
+
122
+ module ModuleTwo
123
+ def method_two
124
+ 2
125
+ end
126
+ end
127
+
128
+ module ModuleThree
129
+ def method_three
130
+ 3
131
+ end
132
+ end
133
+
134
+ it 'extends the world with namespaces' do
135
+ dsl.World(ModuleOne, module_two: ModuleTwo, module_three: ModuleThree)
136
+ rb.begin_scenario(double('scenario').as_null_object)
137
+ class << rb.current_world
138
+ extend RSpec::Matchers
139
+ expect(included_modules.inspect).to match(/ModuleOne/)
140
+ end
141
+ expect(rb.current_world.class).to eq Object
142
+ expect(rb.current_world).to respond_to(:method_one)
143
+
144
+ expect(rb.current_world.module_two.class).to eq Object
145
+ expect(rb.current_world.module_two).to respond_to(:method_two)
146
+
147
+ expect(rb.current_world.module_three.class).to eq Object
148
+ expect(rb.current_world.module_three).to respond_to(:method_three)
149
+ end
150
+
151
+ it 'allows to inspect the included modules' do
152
+ dsl.World(ModuleOne, module_two: ModuleTwo, module_three: ModuleThree)
153
+ rb.begin_scenario(double('scenario').as_null_object)
154
+ class << rb.current_world
155
+ extend RSpec::Matchers
156
+ end
157
+ expect(rb.current_world.inspect).to match(/ModuleOne/)
158
+ expect(rb.current_world.inspect).to include('ModuleTwo (as module_two)')
159
+ expect(rb.current_world.inspect).to include('ModuleThree (as module_three)')
160
+ end
161
+
162
+ it 'merges methods when assigning different modules to the same namespace' do
163
+ dsl.World(namespace: ModuleOne)
164
+ dsl.World(namespace: ModuleTwo)
165
+ rb.begin_scenario(double('scenario').as_null_object)
166
+ class << rb.current_world
167
+ extend RSpec::Matchers
168
+ end
169
+ expect(rb.current_world.namespace).to respond_to(:method_one)
170
+ expect(rb.current_world.namespace).to respond_to(:method_two)
171
+ end
172
+
173
+ it 'resolves conflicts when assigning different modules to the same namespace' do
174
+ dsl.World(namespace: ModuleOne)
175
+ dsl.World(namespace: ModuleMinusOne)
176
+ rb.begin_scenario(double('scenario').as_null_object)
177
+ class << rb.current_world
178
+ extend RSpec::Matchers
179
+ end
180
+ expect(rb.current_world.namespace).to respond_to(:method_one)
181
+ expect(rb.current_world.namespace.method_one).to eql(-1)
182
+ end
183
+ end
184
+
107
185
  describe "step argument transformations" do
108
186
  describe "without capture groups" do
109
187
  it "complains when registering with a with no transform block" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
  require 'cucumber/rb_support/rb_language'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
  require 'cucumber/rb_support/rb_transform'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
  require 'cucumber/formatter/spec_helper'
3
4
  require 'cucumber/formatter/pretty'
@@ -26,7 +27,7 @@ module Cucumber
26
27
 
27
28
  define_steps do
28
29
  When(/^puts is called twice for the same variable$/) do
29
- foo = 'a'
30
+ foo = String.new('a')
30
31
  puts foo
31
32
  foo.upcase!
32
33
  puts foo
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
  require 'cucumber/rb_support/snippet'
3
4