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.
- checksums.yaml +4 -4
- data/.travis.yml +22 -10
- data/CONTRIBUTING.md +13 -0
- data/Gemfile +11 -4
- data/History.md +19 -1
- data/README.md +1 -1
- data/cucumber.gemspec +2 -2
- data/cucumber.yml +2 -2
- data/features/docs/api/listen_for_events.feature +7 -6
- data/features/docs/cli/help.feature +8 -0
- data/features/docs/cli/retry_failing_tests.feature +51 -16
- data/features/docs/defining_steps/nested_steps_i18n.feature +2 -0
- data/features/docs/defining_steps/printing_messages.feature +0 -1
- data/features/docs/defining_steps/skip_scenario.feature +0 -34
- data/features/docs/extending_cucumber/custom_formatter.feature +2 -30
- data/features/docs/formatters/summary_formatter.feature +34 -0
- data/features/docs/gherkin/unicode_table.feature +1 -1
- data/features/docs/post_configuration_hook.feature +0 -16
- data/features/docs/writing_support_code/world.feature +129 -0
- data/features/lib/step_definitions/aruba_steps.rb +1 -0
- data/features/lib/step_definitions/cli_steps.rb +4 -0
- data/features/lib/step_definitions/cucumber_steps.rb +1 -0
- data/features/lib/step_definitions/iso-8859-1_steps.rb +1 -0
- data/features/lib/step_definitions/json_steps.rb +1 -0
- data/features/lib/step_definitions/junit_steps.rb +1 -0
- data/features/lib/step_definitions/language_steps.rb +1 -0
- data/features/lib/step_definitions/profile_steps.rb +1 -0
- data/features/lib/step_definitions/retry_steps.rb +32 -12
- data/features/lib/step_definitions/ruby_steps.rb +1 -0
- data/features/lib/step_definitions/wire_steps.rb +1 -0
- data/features/lib/support/env.rb +2 -1
- data/features/lib/support/fake_wire_server.rb +1 -0
- data/features/lib/support/feature_factory.rb +1 -0
- data/features/lib/support/normalise_output.rb +1 -0
- data/gem_tasks/contributors.rake +1 -0
- data/gem_tasks/cov.rake +1 -0
- data/gem_tasks/cucumber.rake +1 -0
- data/gem_tasks/downloads.rb +1 -0
- data/gem_tasks/environment.rake +1 -0
- data/gem_tasks/examples.rake +2 -1
- data/gem_tasks/fix_cr_lf.rake +2 -1
- data/gem_tasks/flog.rake +2 -1
- data/gem_tasks/rspec.rake +1 -0
- data/gem_tasks/sass.rake +2 -1
- data/lib/autotest/cucumber.rb +1 -0
- data/lib/autotest/cucumber_mixin.rb +1 -0
- data/lib/autotest/cucumber_rails.rb +1 -0
- data/lib/autotest/cucumber_rails_rspec.rb +1 -0
- data/lib/autotest/cucumber_rails_rspec2.rb +1 -0
- data/lib/autotest/cucumber_rspec.rb +1 -0
- data/lib/autotest/cucumber_rspec2.rb +1 -0
- data/lib/autotest/discover.rb +1 -0
- data/lib/cucumber.rb +1 -13
- data/lib/cucumber/cli/configuration.rb +3 -6
- data/lib/cucumber/cli/main.rb +2 -1
- data/lib/cucumber/cli/options.rb +239 -173
- data/lib/cucumber/cli/profile_loader.rb +1 -0
- data/lib/cucumber/cli/rerun_file.rb +1 -0
- data/lib/cucumber/configuration.rb +40 -19
- data/lib/cucumber/constantize.rb +1 -0
- data/lib/cucumber/core_ext/instance_exec.rb +1 -0
- data/lib/cucumber/core_ext/string.rb +1 -0
- data/lib/cucumber/deprecate.rb +1 -0
- data/lib/cucumber/encoding.rb +1 -0
- data/lib/cucumber/errors.rb +3 -1
- data/lib/cucumber/events.rb +13 -3
- data/lib/cucumber/events/step_definition_registered.rb +24 -0
- data/lib/cucumber/events/step_match.rb +4 -1
- data/lib/cucumber/events/test_run_finished.rb +12 -0
- data/lib/cucumber/file_specs.rb +1 -0
- data/lib/cucumber/filters.rb +2 -0
- data/lib/cucumber/filters/activate_steps.rb +2 -1
- data/lib/cucumber/filters/apply_after_hooks.rb +1 -0
- data/lib/cucumber/filters/apply_after_step_hooks.rb +1 -0
- data/lib/cucumber/filters/apply_around_hooks.rb +1 -0
- data/lib/cucumber/filters/apply_before_hooks.rb +1 -0
- data/lib/cucumber/filters/gated_receiver.rb +1 -0
- data/lib/cucumber/filters/prepare_world.rb +1 -0
- data/lib/cucumber/filters/quit.rb +1 -0
- data/lib/cucumber/filters/randomizer.rb +1 -0
- data/lib/cucumber/filters/retry.rb +3 -3
- data/lib/cucumber/filters/tag_limits.rb +1 -0
- data/lib/cucumber/filters/tag_limits/test_case_index.rb +1 -0
- data/lib/cucumber/filters/tag_limits/verifier.rb +1 -0
- data/lib/cucumber/formatter/ansicolor.rb +1 -0
- data/lib/cucumber/formatter/backtrace_filter.rb +3 -2
- data/lib/cucumber/formatter/console.rb +61 -52
- data/lib/cucumber/formatter/console_counts.rb +57 -0
- data/lib/cucumber/formatter/console_issues.rb +37 -0
- data/lib/cucumber/formatter/debug.rb +1 -0
- data/lib/cucumber/formatter/duration.rb +1 -0
- data/lib/cucumber/formatter/duration_extractor.rb +1 -0
- data/lib/cucumber/formatter/fail_fast.rb +4 -2
- data/lib/cucumber/formatter/fanout.rb +1 -0
- data/lib/cucumber/formatter/hook_query_visitor.rb +1 -0
- data/lib/cucumber/formatter/html.rb +6 -5
- data/lib/cucumber/formatter/ignore_missing_messages.rb +1 -0
- data/lib/cucumber/formatter/interceptor.rb +1 -0
- data/lib/cucumber/formatter/io.rb +1 -0
- data/lib/cucumber/formatter/json.rb +15 -13
- data/lib/cucumber/formatter/json_pretty.rb +1 -0
- data/lib/cucumber/formatter/junit.rb +13 -11
- data/lib/cucumber/formatter/legacy_api/adapter.rb +28 -32
- data/lib/cucumber/formatter/legacy_api/ast.rb +1 -0
- data/lib/cucumber/formatter/legacy_api/results.rb +1 -0
- data/lib/cucumber/formatter/legacy_api/runtime_facade.rb +1 -0
- data/lib/cucumber/formatter/pretty.rb +7 -1
- data/lib/cucumber/formatter/progress.rb +56 -13
- data/lib/cucumber/formatter/rerun.rb +15 -18
- data/lib/cucumber/formatter/stepdefs.rb +1 -0
- data/lib/cucumber/formatter/steps.rb +1 -0
- data/lib/cucumber/formatter/summary.rb +43 -20
- data/lib/cucumber/formatter/unicode.rb +1 -0
- data/lib/cucumber/formatter/usage.rb +26 -21
- data/lib/cucumber/gherkin/data_table_parser.rb +1 -0
- data/lib/cucumber/gherkin/formatter/ansi_escapes.rb +1 -0
- data/lib/cucumber/gherkin/formatter/escaping.rb +1 -0
- data/lib/cucumber/gherkin/i18n.rb +1 -0
- data/lib/cucumber/gherkin/steps_parser.rb +1 -0
- data/lib/cucumber/hooks.rb +1 -0
- data/lib/cucumber/load_path.rb +1 -0
- data/lib/cucumber/multiline_argument.rb +1 -2
- data/lib/cucumber/multiline_argument/data_table.rb +3 -1
- data/lib/cucumber/multiline_argument/doc_string.rb +1 -0
- data/lib/cucumber/platform.rb +1 -0
- data/lib/cucumber/project_initializer.rb +2 -1
- data/lib/cucumber/rake/task.rb +1 -0
- data/lib/cucumber/rb_support/rb_dsl.rb +11 -9
- data/lib/cucumber/rb_support/rb_hook.rb +1 -0
- data/lib/cucumber/rb_support/rb_language.rb +19 -8
- data/lib/cucumber/rb_support/rb_step_definition.rb +1 -0
- data/lib/cucumber/rb_support/rb_transform.rb +1 -0
- data/lib/cucumber/rb_support/rb_world.rb +42 -20
- data/lib/cucumber/rb_support/snippet.rb +2 -1
- data/lib/cucumber/rspec/disable_option_parser.rb +1 -0
- data/lib/cucumber/rspec/doubles.rb +1 -0
- data/lib/cucumber/running_test_case.rb +1 -25
- data/lib/cucumber/runtime.rb +15 -10
- data/lib/cucumber/runtime/after_hooks.rb +1 -0
- data/lib/cucumber/runtime/before_hooks.rb +1 -0
- data/lib/cucumber/runtime/for_programming_languages.rb +1 -0
- data/lib/cucumber/runtime/step_hooks.rb +1 -0
- data/lib/cucumber/runtime/support_code.rb +1 -0
- data/lib/cucumber/runtime/user_interface.rb +1 -0
- data/lib/cucumber/step_argument.rb +1 -0
- data/lib/cucumber/step_definition_light.rb +1 -0
- data/lib/cucumber/step_definitions.rb +1 -0
- data/lib/cucumber/step_match.rb +1 -0
- data/lib/cucumber/step_match_search.rb +1 -0
- data/lib/cucumber/term/ansicolor.rb +1 -0
- data/lib/cucumber/unit.rb +1 -0
- data/lib/cucumber/version +1 -1
- data/lib/simplecov_setup.rb +1 -0
- data/spec/cucumber/cli/configuration_spec.rb +1 -0
- data/spec/cucumber/cli/main_spec.rb +1 -0
- data/spec/cucumber/cli/options_spec.rb +1 -0
- data/spec/cucumber/cli/profile_loader_spec.rb +1 -0
- data/spec/cucumber/cli/rerun_spec.rb +1 -0
- data/spec/cucumber/configuration_spec.rb +1 -0
- data/spec/cucumber/constantize_spec.rb +1 -0
- data/spec/cucumber/core_ext/instance_exec_spec.rb +1 -0
- data/spec/cucumber/file_specs_spec.rb +1 -0
- data/spec/cucumber/filters/activate_steps_spec.rb +9 -6
- data/spec/cucumber/filters/gated_receiver_spec.rb +1 -0
- data/spec/cucumber/filters/retry_spec.rb +27 -21
- data/spec/cucumber/filters/tag_limits/test_case_index_spec.rb +1 -0
- data/spec/cucumber/filters/tag_limits/verifier_spec.rb +1 -0
- data/spec/cucumber/filters/tag_limits_spec.rb +1 -0
- data/spec/cucumber/formatter/ansicolor_spec.rb +1 -0
- data/spec/cucumber/formatter/console_counts_spec.rb +14 -0
- data/spec/cucumber/formatter/debug_spec.rb +1 -0
- data/spec/cucumber/formatter/duration_spec.rb +1 -0
- data/spec/cucumber/formatter/fail_fast_spec.rb +5 -5
- data/spec/cucumber/formatter/html_spec.rb +6 -1
- data/spec/cucumber/formatter/interceptor_spec.rb +1 -0
- data/spec/cucumber/formatter/json_spec.rb +29 -28
- data/spec/cucumber/formatter/junit_spec.rb +1 -0
- data/spec/cucumber/formatter/legacy_api/adapter_spec.rb +8 -3
- data/spec/cucumber/formatter/pretty_spec.rb +1 -0
- data/spec/cucumber/formatter/progress_spec.rb +2 -1
- data/spec/cucumber/formatter/rerun_spec.rb +70 -64
- data/spec/cucumber/formatter/spec_helper.rb +8 -7
- data/spec/cucumber/hooks_spec.rb +1 -0
- data/spec/cucumber/multiline_argument/data_table_spec.rb +1 -0
- data/spec/cucumber/project_initializer_spec.rb +2 -1
- data/spec/cucumber/rake/forked_spec.rb +1 -0
- data/spec/cucumber/rake/task_spec.rb +1 -0
- data/spec/cucumber/rb_support/rb_language_spec.rb +81 -3
- data/spec/cucumber/rb_support/rb_step_definition_spec.rb +1 -0
- data/spec/cucumber/rb_support/rb_transform_spec.rb +1 -0
- data/spec/cucumber/rb_support/rb_world_spec.rb +2 -1
- data/spec/cucumber/rb_support/snippet_spec.rb +1 -0
- data/spec/cucumber/running_test_case_spec.rb +1 -0
- data/spec/cucumber/runtime/for_programming_languages_spec.rb +1 -0
- data/spec/cucumber/runtime/support_code_spec.rb +1 -0
- data/spec/cucumber/runtime_spec.rb +1 -0
- data/spec/cucumber/step_argument_spec.rb +1 -0
- data/spec/cucumber/step_match_search_spec.rb +1 -0
- data/spec/cucumber/step_match_spec.rb +1 -0
- data/spec/cucumber/world/pending_spec.rb +1 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/standard_step_actions.rb +1 -0
- metadata +24 -23
- data/lib/cucumber/ast.rb +0 -13
- data/lib/cucumber/events/after_test_case.rb +0 -25
- data/lib/cucumber/events/after_test_step.rb +0 -30
- data/lib/cucumber/events/before_test_case.rb +0 -18
- data/lib/cucumber/events/before_test_step.rb +0 -23
- data/lib/cucumber/events/bus.rb +0 -86
- data/lib/cucumber/events/finished_testing.rb +0 -9
- data/lib/cucumber/formatter/event_bus_report.rb +0 -38
- data/spec/cucumber/events/bus_spec.rb +0 -94
- data/spec/cucumber/formatter/event_bus_report_spec.rb +0 -88
- data/spec/cucumber_spec.rb +0 -39
@@ -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(
|
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(
|
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/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(
|
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
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
30
|
-
|
31
|
-
|
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
|
-
|
40
|
+
expect( io.string ).to eq 'foo.feature:3:6'
|
41
|
+
end
|
36
42
|
end
|
37
|
-
end
|
38
43
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
66
|
-
|
70
|
+
Rerun.new(config)
|
71
|
+
execute [foo, bar], [StandardStepActions.new], config.event_bus
|
72
|
+
config.event_bus.test_run_finished
|
67
73
|
|
68
|
-
|
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
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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
|
-
|
85
|
-
|
88
|
+
Rerun.new(config)
|
89
|
+
execute [gherkin], [StandardStepActions.new], config.event_bus
|
90
|
+
config.event_bus.test_run_finished
|
86
91
|
|
87
|
-
|
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(
|
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
|
-
|
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
|
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
|
data/spec/cucumber/hooks_spec.rb
CHANGED
@@ -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(
|
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("
|
48
|
+
a_file_called("docs.md") do
|
47
49
|
"yo"
|
48
50
|
end
|
49
|
-
rb.load_code_file('
|
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/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
|