cucumber 2.0.0.beta.5 → 2.0.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +20 -1
  3. data/Rakefile +0 -2
  4. data/cucumber.gemspec +1 -1
  5. data/features/docs/defining_steps/skip_scenario.feature +31 -2
  6. data/lib/cucumber.rb +6 -0
  7. data/lib/cucumber/ast/facade.rb +117 -0
  8. data/lib/cucumber/cli/configuration.rb +1 -1
  9. data/lib/cucumber/cli/profile_loader.rb +1 -1
  10. data/lib/cucumber/file_specs.rb +1 -1
  11. data/lib/cucumber/filters.rb +9 -0
  12. data/lib/cucumber/filters/activate_steps.rb +34 -0
  13. data/lib/cucumber/filters/apply_after_hooks.rb +9 -0
  14. data/lib/cucumber/filters/apply_after_step_hooks.rb +12 -0
  15. data/lib/cucumber/filters/apply_around_hooks.rb +12 -0
  16. data/lib/cucumber/filters/apply_before_hooks.rb +9 -0
  17. data/lib/cucumber/filters/prepare_world.rb +37 -0
  18. data/lib/cucumber/filters/quit.rb +5 -1
  19. data/lib/cucumber/filters/randomizer.rb +5 -1
  20. data/lib/cucumber/filters/tag_limits.rb +7 -2
  21. data/lib/cucumber/formatter/ansicolor.rb +0 -8
  22. data/lib/cucumber/formatter/html.rb +6 -1
  23. data/lib/cucumber/formatter/legacy_api/adapter.rb +17 -1
  24. data/lib/cucumber/formatter/legacy_api/ast.rb +6 -1
  25. data/lib/cucumber/hooks.rb +97 -0
  26. data/lib/cucumber/platform.rb +2 -3
  27. data/lib/cucumber/rb_support/rb_hook.rb +2 -2
  28. data/lib/cucumber/runtime.rb +18 -15
  29. data/lib/cucumber/runtime/after_hooks.rb +24 -0
  30. data/lib/cucumber/runtime/before_hooks.rb +23 -0
  31. data/lib/cucumber/runtime/step_hooks.rb +22 -0
  32. data/lib/cucumber/runtime/support_code.rb +56 -1
  33. data/lib/cucumber/step_match.rb +26 -2
  34. data/spec/cucumber/cli/configuration_spec.rb +16 -1
  35. data/spec/cucumber/cli/profile_loader_spec.rb +10 -0
  36. data/spec/cucumber/file_specs_spec.rb +10 -2
  37. data/spec/cucumber/filters/activate_steps_spec.rb +57 -0
  38. data/spec/cucumber/formatter/debug_spec.rb +0 -14
  39. data/spec/cucumber/formatter/html_spec.rb +29 -0
  40. data/spec/cucumber/formatter/legacy_api/adapter_spec.rb +210 -110
  41. data/spec/cucumber/formatter/pretty_spec.rb +0 -2
  42. data/spec/cucumber/formatter/rerun_spec.rb +17 -16
  43. data/spec/cucumber/formatter/spec_helper.rb +11 -6
  44. data/spec/cucumber/hooks_spec.rb +30 -0
  45. data/spec/cucumber/rb_support/rb_step_definition_spec.rb +11 -4
  46. metadata +22 -16
  47. data/gem_tasks/yard.rake +0 -43
  48. data/gem_tasks/yard/default/layout/html/bubble_32x32.png +0 -0
  49. data/gem_tasks/yard/default/layout/html/footer.erb +0 -5
  50. data/gem_tasks/yard/default/layout/html/index.erb +0 -1
  51. data/gem_tasks/yard/default/layout/html/layout.erb +0 -25
  52. data/gem_tasks/yard/default/layout/html/logo.erb +0 -1
  53. data/gem_tasks/yard/default/layout/html/setup.rb +0 -4
  54. data/lib/cucumber/mappings.rb +0 -238
  55. data/spec/cucumber/mappings_spec.rb +0 -180
@@ -534,7 +534,6 @@ OUTPUT
534
534
 
535
535
  context "In --expand mode" do
536
536
  let(:runtime) { Runtime.new({:expand => true})}
537
- let(:mappings) { Mappings.new(runtime) }
538
537
  before(:each) do
539
538
  Cucumber::Term::ANSIColor.coloring = false
540
539
  @out = StringIO.new
@@ -624,7 +623,6 @@ OUTPUT
624
623
 
625
624
  context "In --expand mode with --source as an option" do
626
625
  let(:runtime) { Runtime.new({:expand => true})}
627
- let(:mappings) { Mappings.new(runtime) }
628
626
  before(:each) do
629
627
  Cucumber::Term::ANSIColor.coloring = false
630
628
  @out = StringIO.new
@@ -1,6 +1,7 @@
1
1
  require 'cucumber/formatter/rerun'
2
2
  require 'cucumber/core'
3
3
  require 'cucumber/core/gherkin/writer'
4
+ require 'cucumber/core/filter'
4
5
 
5
6
  module Cucumber::Formatter
6
7
  describe Rerun do
@@ -9,17 +10,20 @@ module Cucumber::Formatter
9
10
 
10
11
  # after_test_case
11
12
  context 'when 2 scenarios fail in the same file' do
12
- class StepTestMappings
13
- Failure = Class.new(StandardError)
14
-
15
- def test_case(test_case, mapper)
16
- self
17
- end
13
+ class WithSteps < Cucumber::Core::Filter.new
14
+ def test_case(test_case)
15
+ test_steps = test_case.test_steps.map do |step|
16
+ case step.name
17
+ when /fail/
18
+ step.with_action { raise Failure }
19
+ when /pass/
20
+ step.with_action {}
21
+ else
22
+ step
23
+ end
24
+ end
18
25
 
19
- def test_step(step, mapper)
20
- mapper.map { raise Failure } if step.name =~ /fail/
21
- mapper.map {} if step.name =~ /pass/
22
- self
26
+ test_case.with_steps(test_steps).describe_to(receiver)
23
27
  end
24
28
  end
25
29
 
@@ -41,9 +45,8 @@ module Cucumber::Formatter
41
45
  end
42
46
  io = StringIO.new
43
47
  report = Rerun.new(double, io, double)
44
- mappings = StepTestMappings.new
45
48
 
46
- execute [gherkin], mappings, report
49
+ execute [gherkin], report, [WithSteps.new]
47
50
 
48
51
  expect( io.string ).to eq 'foo.feature:3:6'
49
52
  end
@@ -77,9 +80,8 @@ module Cucumber::Formatter
77
80
 
78
81
  io = StringIO.new
79
82
  report = Rerun.new(double, io, double)
80
- mappings = StepTestMappings.new
81
83
 
82
- execute [foo, bar], mappings, report
84
+ execute [foo, bar], report, [WithSteps.new]
83
85
 
84
86
  expect(io.string).to eq 'foo.feature:3:6 bar.feature:3'
85
87
  end
@@ -97,9 +99,8 @@ module Cucumber::Formatter
97
99
 
98
100
  io = StringIO.new
99
101
  report = Rerun.new(double, io, double)
100
- mappings = StepTestMappings.new
101
102
 
102
- execute [gherkin], mappings, report
103
+ execute [gherkin], report, [WithSteps.new]
103
104
  end
104
105
  end
105
106
  end
@@ -20,12 +20,17 @@ module Cucumber
20
20
  def run_defined_feature
21
21
  define_steps
22
22
  runtime.visitor = report
23
- execute [gherkin_doc], mappings, report
24
- end
25
23
 
26
- require 'cucumber/mappings'
27
- def mappings
28
- @mappings ||= Mappings.new
24
+ receiver = Test::Runner.new(report)
25
+ filters = [
26
+ Filters::ActivateSteps.new(runtime.support_code),
27
+ Filters::ApplyAfterStepHooks.new(runtime.support_code),
28
+ Filters::ApplyBeforeHooks.new(runtime.support_code),
29
+ Filters::ApplyAfterHooks.new(runtime.support_code),
30
+ Filters::ApplyAroundHooks.new(runtime.support_code),
31
+ Filters::PrepareWorld.new(runtime)
32
+ ]
33
+ compile [gherkin_doc], receiver, filters
29
34
  end
30
35
 
31
36
  require 'cucumber/formatter/legacy_api/adapter'
@@ -47,7 +52,7 @@ module Cucumber
47
52
  end
48
53
 
49
54
  def runtime
50
- mappings.runtime
55
+ @runtime ||= Runtime.new
51
56
  end
52
57
 
53
58
  def define_steps
@@ -0,0 +1,30 @@
1
+ require 'cucumber/hooks'
2
+ module Cucumber::Hooks
3
+ shared_examples_for 'a source node' do
4
+ it "responds to name" do
5
+ expect( subject.name ).to be_a(String)
6
+ end
7
+
8
+ it "responds to location" do
9
+ expect( subject.location ).to eq(location)
10
+ end
11
+
12
+ it "responds to match_locations?" do
13
+ expect( subject.match_locations? [location] ).to be_truthy
14
+ expect( subject.match_locations? [] ).to be_falsey
15
+ end
16
+ end
17
+
18
+ require 'cucumber/core/ast/location'
19
+ describe BeforeHook do
20
+ subject { BeforeHook.new(location) }
21
+ let(:location) { Cucumber::Core::Ast::Location.new('hooks.rb', 1) }
22
+ it_behaves_like 'a source node'
23
+ end
24
+
25
+ describe AfterHook do
26
+ subject { AfterHook.new(location) }
27
+ let(:location) { Cucumber::Core::Ast::Location.new('hooks.rb', 1) }
28
+ it_behaves_like 'a source node'
29
+ end
30
+ end
@@ -18,7 +18,11 @@ module Cucumber
18
18
  end
19
19
 
20
20
  def run_step(text)
21
- support_code.step_match(text).invoke(MultilineArgument::None.new)
21
+ step_match(text).invoke(MultilineArgument::None.new)
22
+ end
23
+
24
+ def step_match(text)
25
+ support_code.step_match(text)
22
26
  end
23
27
 
24
28
  it "allows calling of other steps" do
@@ -111,14 +115,17 @@ module Cucumber
111
115
  }).to raise_error(Cucumber::ArityMismatchError)
112
116
  end
113
117
 
114
- it "does not allow modification of args since it messes up pretty formatting" do
118
+ it "does not modify the step_match arg when arg is modified in a step" do
115
119
  dsl.Given(/My car is (.*)/) do |colour|
116
120
  colour << "xxx"
117
121
  end
118
122
 
123
+ step_name = "My car is white"
124
+ step_args = step_match(step_name).args
125
+
119
126
  expect(-> {
120
- run_step "My car is white"
121
- }).to raise_error(RuntimeError, /can't modify frozen String/i)
127
+ run_step step_name
128
+ }).not_to change{ step_args.first }
122
129
  end
123
130
 
124
131
  it "allows puts" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta.5
4
+ version: 2.0.0.rc.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aslak Hellesøy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-18 00:00:00.000000000 Z
11
+ date: 2015-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber-core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.0.beta.4
19
+ version: 1.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.0.beta.4
26
+ version: 1.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: builder
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -645,13 +645,6 @@ files:
645
645
  - gem_tasks/sass.rake
646
646
  - gem_tasks/stats
647
647
  - gem_tasks/versions.txt
648
- - gem_tasks/yard.rake
649
- - gem_tasks/yard/default/layout/html/bubble_32x32.png
650
- - gem_tasks/yard/default/layout/html/footer.erb
651
- - gem_tasks/yard/default/layout/html/index.erb
652
- - gem_tasks/yard/default/layout/html/layout.erb
653
- - gem_tasks/yard/default/layout/html/logo.erb
654
- - gem_tasks/yard/default/layout/html/setup.rb
655
648
  - lib/autotest/cucumber.rb
656
649
  - lib/autotest/cucumber_mixin.rb
657
650
  - lib/autotest/cucumber_rails.rb
@@ -662,6 +655,7 @@ files:
662
655
  - lib/autotest/discover.rb
663
656
  - lib/cucumber.rb
664
657
  - lib/cucumber/ast.rb
658
+ - lib/cucumber/ast/facade.rb
665
659
  - lib/cucumber/cli/configuration.rb
666
660
  - lib/cucumber/cli/main.rb
667
661
  - lib/cucumber/cli/options.rb
@@ -673,7 +667,14 @@ files:
673
667
  - lib/cucumber/core_ext/string.rb
674
668
  - lib/cucumber/errors.rb
675
669
  - lib/cucumber/file_specs.rb
670
+ - lib/cucumber/filters.rb
671
+ - lib/cucumber/filters/activate_steps.rb
672
+ - lib/cucumber/filters/apply_after_hooks.rb
673
+ - lib/cucumber/filters/apply_after_step_hooks.rb
674
+ - lib/cucumber/filters/apply_around_hooks.rb
675
+ - lib/cucumber/filters/apply_before_hooks.rb
676
676
  - lib/cucumber/filters/gated_receiver.rb
677
+ - lib/cucumber/filters/prepare_world.rb
677
678
  - lib/cucumber/filters/quit.rb
678
679
  - lib/cucumber/filters/randomizer.rb
679
680
  - lib/cucumber/filters/tag_limits.rb
@@ -708,10 +709,10 @@ files:
708
709
  - lib/cucumber/formatter/summary.rb
709
710
  - lib/cucumber/formatter/unicode.rb
710
711
  - lib/cucumber/formatter/usage.rb
712
+ - lib/cucumber/hooks.rb
711
713
  - lib/cucumber/language_support.rb
712
714
  - lib/cucumber/language_support/language_methods.rb
713
715
  - lib/cucumber/load_path.rb
714
- - lib/cucumber/mappings.rb
715
716
  - lib/cucumber/multiline_argument.rb
716
717
  - lib/cucumber/multiline_argument/data_table.rb
717
718
  - lib/cucumber/multiline_argument/doc_string.rb
@@ -728,7 +729,10 @@ files:
728
729
  - lib/cucumber/rspec/disable_option_parser.rb
729
730
  - lib/cucumber/rspec/doubles.rb
730
731
  - lib/cucumber/runtime.rb
732
+ - lib/cucumber/runtime/after_hooks.rb
733
+ - lib/cucumber/runtime/before_hooks.rb
731
734
  - lib/cucumber/runtime/for_programming_languages.rb
735
+ - lib/cucumber/runtime/step_hooks.rb
732
736
  - lib/cucumber/runtime/support_code.rb
733
737
  - lib/cucumber/runtime/user_interface.rb
734
738
  - lib/cucumber/step_definition_light.rb
@@ -753,6 +757,7 @@ files:
753
757
  - spec/cucumber/constantize_spec.rb
754
758
  - spec/cucumber/core_ext/proc_spec.rb
755
759
  - spec/cucumber/file_specs_spec.rb
760
+ - spec/cucumber/filters/activate_steps_spec.rb
756
761
  - spec/cucumber/filters/gated_receiver_spec.rb
757
762
  - spec/cucumber/filters/tag_limits/test_case_index_spec.rb
758
763
  - spec/cucumber/filters/tag_limits/verifier_spec.rb
@@ -768,7 +773,7 @@ files:
768
773
  - spec/cucumber/formatter/progress_spec.rb
769
774
  - spec/cucumber/formatter/rerun_spec.rb
770
775
  - spec/cucumber/formatter/spec_helper.rb
771
- - spec/cucumber/mappings_spec.rb
776
+ - spec/cucumber/hooks_spec.rb
772
777
  - spec/cucumber/multiline_argument/data_table_spec.rb
773
778
  - spec/cucumber/rake/forked_spec.rb
774
779
  - spec/cucumber/rb_support/rb_language_spec.rb
@@ -810,10 +815,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
810
815
  version: 1.3.1
811
816
  requirements: []
812
817
  rubyforge_project:
813
- rubygems_version: 2.4.5
818
+ rubygems_version: 2.2.2
814
819
  signing_key:
815
820
  specification_version: 4
816
- summary: cucumber-2.0.0.beta.5
821
+ summary: cucumber-2.0.0.rc.1
817
822
  test_files:
818
823
  - features/docs/api/list_step_defs_as_json.feature
819
824
  - features/docs/api/run_cli_main_with_existing_runtime.feature
@@ -900,6 +905,7 @@ test_files:
900
905
  - spec/cucumber/constantize_spec.rb
901
906
  - spec/cucumber/core_ext/proc_spec.rb
902
907
  - spec/cucumber/file_specs_spec.rb
908
+ - spec/cucumber/filters/activate_steps_spec.rb
903
909
  - spec/cucumber/filters/gated_receiver_spec.rb
904
910
  - spec/cucumber/filters/tag_limits/test_case_index_spec.rb
905
911
  - spec/cucumber/filters/tag_limits/verifier_spec.rb
@@ -915,7 +921,7 @@ test_files:
915
921
  - spec/cucumber/formatter/progress_spec.rb
916
922
  - spec/cucumber/formatter/rerun_spec.rb
917
923
  - spec/cucumber/formatter/spec_helper.rb
918
- - spec/cucumber/mappings_spec.rb
924
+ - spec/cucumber/hooks_spec.rb
919
925
  - spec/cucumber/multiline_argument/data_table_spec.rb
920
926
  - spec/cucumber/rake/forked_spec.rb
921
927
  - spec/cucumber/rb_support/rb_language_spec.rb
@@ -1,43 +0,0 @@
1
- require 'yard'
2
- require 'yard/rake/yardoc_task'
3
- require File.expand_path(File.dirname(__FILE__) + '/../lib/cucumber/platform')
4
-
5
- DOC_DIR = File.expand_path(File.dirname(__FILE__) + '/../doc')
6
- SITE_DIR = File.expand_path(File.dirname(__FILE__) + '/../../cucumber.github.com')
7
- API_DIR = File.join(SITE_DIR, 'api', 'cucumber', 'ruby', 'yardoc')
8
- TEMPLATE_DIR = File.expand_path(File.join(File.dirname(__FILE__), 'yard'))
9
- YARD::Templates::Engine.register_template_path(TEMPLATE_DIR)
10
-
11
- namespace :api do
12
- YARD::Rake::YardocTask.new(:yard) do |yard|
13
- yard.options = ["--out", DOC_DIR]
14
- end
15
-
16
- task :sync_with_git do
17
- unless File.directory?(SITE_DIR)
18
- raise "You need to git clone git@github.com:cucumber/cucumber.github.com.git #{SITE_DIR}"
19
- end
20
- Dir.chdir(SITE_DIR) do
21
- sh 'git pull -u'
22
- end
23
- end
24
-
25
- task :copy_to_website do
26
- rm_rf API_DIR
27
- cp_r DOC_DIR, API_DIR
28
- end
29
-
30
- task :release do
31
- Dir.chdir(SITE_DIR) do
32
- sh 'git add .'
33
- sh '''git commit -m "Update API docs for Cucumber-Ruby v#{Cucumber::VERSION}"'''
34
- sh 'git push'
35
- end
36
- end
37
-
38
- desc "Generate YARD docs for Cucumber's API"
39
- task :doc => [:yard, :sync_with_git, :copy_to_website, :release]
40
-
41
- desc "Build cucumber gem and doc locally"
42
- task :build => [:yard, :sync_with_git, :copy_to_website]
43
- end
@@ -1,5 +0,0 @@
1
- <div id="footer">
2
- Generated on <%= Time.now.strftime("%c") %> by
3
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
4
- <%= YARD::VERSION %> (ruby-<%= RUBY_VERSION %>).
5
- </div>
@@ -1 +0,0 @@
1
- <%= yieldall %>
@@ -1,25 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
- <head>
5
- <%= erb(:headers) %>
6
- </head>
7
- <body>
8
- <script type="text/javascript" charset="utf-8">
9
- if (window.top.frames.main) document.body.className = 'frames';
10
- </script>
11
-
12
- <div id="header">
13
- <%= erb(:logo) %>
14
- <%= erb(:breadcrumb) %>
15
- <%= erb(:search) %>
16
- <div class="clear"></div>
17
- </div>
18
-
19
- <iframe id="search_frame"></iframe>
20
-
21
- <div id="content"><%= yieldall %></div>
22
-
23
- <%= erb(:footer) %>
24
- </body>
25
- </html>
@@ -1 +0,0 @@
1
- <h3><img src="<%= url_for('images/bubble_32x32.png') %>"></img> Cucumber <%= Cucumber::VERSION %></h3>
@@ -1,4 +0,0 @@
1
- def init
2
- super
3
- options[:serializer].serialize('/images/bubble_32x32.png', IO.read(File.dirname(__FILE__) + '/bubble_32x32.png'))
4
- end
@@ -1,238 +0,0 @@
1
- require 'cucumber/runtime'
2
- require 'cucumber'
3
- require 'cucumber/multiline_argument'
4
-
5
- module Cucumber
6
- class Mappings
7
-
8
- def self.for(runtime)
9
- if runtime.dry_run?
10
- Mappings::DryRun.new(runtime)
11
- else
12
- Mappings.new(runtime)
13
- end
14
- end
15
-
16
- def initialize(runtime = nil)
17
- @runtime = runtime
18
- end
19
-
20
- def test_step(step, mapper)
21
- map_step(step, mapper)
22
- map_after_step_hooks(mapper)
23
- end
24
-
25
- def test_case(test_case, mapper)
26
- map_test_case(test_case, mapper)
27
- map_test_case_hooks(mapper)
28
- end
29
-
30
- def runtime
31
- return @runtime if @runtime
32
- result = Cucumber::Runtime.new
33
- result.support_code.load_files!(support_files)
34
- @runtime = result
35
- end
36
-
37
- private
38
-
39
- attr_reader :scenario
40
- private :scenario
41
-
42
- def ruby
43
- @ruby ||= runtime.load_programming_language('rb')
44
- end
45
-
46
- def support_files
47
- Dir['features/**/*.rb']
48
- end
49
-
50
- def map_step(step, mapper)
51
- step.describe_source_to MapStep.new(runtime, mapper)
52
- end
53
-
54
- def map_after_step_hooks(mapper)
55
- ruby.hooks_for(:after_step, scenario).each do |hook|
56
- mapper.after do
57
- hook.invoke 'AfterStep', scenario
58
- end
59
- end
60
- end
61
-
62
- def map_test_case(test_case, mapper)
63
- @scenario = Source.new(test_case).build_scenario
64
- mapper.before do
65
- runtime.begin_scenario(scenario)
66
- end
67
- end
68
-
69
- def map_test_case_hooks(mapper)
70
- ruby.hooks_for(:before, scenario).each do |hook|
71
- mapper.before do |result|
72
- hook.invoke('Before', scenario.with_result(result))
73
- end
74
- end
75
- ruby.hooks_for(:after, scenario).each do |hook|
76
- mapper.after do |result|
77
- hook.invoke('After', scenario.with_result(result))
78
- end
79
- end
80
- ruby.hooks_for(:around, scenario).each do |hook|
81
- mapper.around do |run_scenario|
82
- hook.invoke('Around', scenario, &run_scenario)
83
- end
84
- end
85
- end
86
-
87
- # adapts our test_case to look like the Cucumber Runtime's old Scenario
88
- class TestCase
89
- def initialize(test_case, feature, result = Core::Test::Result::Unknown.new)
90
- @test_case = test_case
91
- @feature = feature
92
- @result = result
93
- end
94
-
95
- def accept_hook?(hook)
96
- hook.tag_expressions.all? { |expression| @test_case.match_tags?(expression) }
97
- end
98
-
99
- def failed?
100
- @result.failed?
101
- end
102
-
103
- def language
104
- @test_case.language
105
- end
106
-
107
- def feature
108
- @feature
109
- end
110
-
111
- def name
112
- @test_case.name
113
- end
114
-
115
- def title
116
- warn("deprecated: call #name instead")
117
- name
118
- end
119
-
120
- def source_tags
121
- #warn('deprecated: call #tags instead')
122
- tags
123
- end
124
-
125
- def source_tag_names
126
- tags.map &:name
127
- end
128
-
129
- def tags
130
- @test_case.tags
131
- end
132
-
133
- def outline?
134
- false
135
- end
136
-
137
- def with_result(result)
138
- self.class.new(@test_case, @feature, result)
139
- end
140
- end
141
-
142
- class Scenario < TestCase
143
- end
144
-
145
- class ScenarioOutlineExample < TestCase
146
- def outline?
147
- true
148
- end
149
-
150
- def scenario_outline
151
- self
152
- end
153
- end
154
-
155
- class Source
156
- def initialize(test_case)
157
- @test_case = test_case
158
- test_case.describe_source_to(self)
159
- end
160
-
161
- def feature(feature)
162
- @feature = feature
163
- end
164
-
165
- def scenario(scenario)
166
- @factory = Scenario
167
- end
168
-
169
- def scenario_outline(scenario)
170
- @factory = ScenarioOutlineExample
171
- end
172
-
173
- def examples_table(examples_table)
174
- end
175
-
176
- def examples_table_row(row)
177
- end
178
-
179
- def build_scenario
180
- @factory.new(@test_case, Feature.new(@feature.legacy_conflated_name_and_description))
181
- end
182
- end
183
-
184
- class DryRun < Mappings
185
-
186
- private
187
-
188
- def map_test_case(*)
189
- # NOOP - we don't want to create World etc for dry run
190
- end
191
-
192
- def map_step(step, mapper)
193
- step.describe_source_to MapStep::DryRun.new(runtime, mapper)
194
- end
195
-
196
- def map_after_step_hooks(mapper)
197
- # NOOP - we don't need after step hooks for dry run
198
- end
199
-
200
- def map_test_case_hooks(mapper)
201
- # NOOP - we don't need hooks for dry run
202
- end
203
- end
204
-
205
- Feature = Struct.new(:name)
206
-
207
- class MapStep
208
- include Cucumber.initializer(:runtime, :mapper)
209
-
210
- def step(node)
211
- step_match = runtime.step_match(node.name)
212
- map_step(node, step_match)
213
- rescue Cucumber::Undefined
214
- end
215
-
216
- def feature(*);end
217
- def scenario(*);end
218
- def background(*);end
219
- def scenario_outline(*);end
220
- def examples_table(*);end
221
- def examples_table_row(*);end
222
-
223
- private
224
- def map_step(node, step_match)
225
- multiline_arg = MultilineArgument.from_core(node.multiline_arg)
226
- mapper.map { step_match.invoke(multiline_arg) }
227
- end
228
-
229
- class DryRun < MapStep
230
- private
231
- def map_step(node, step_match)
232
- mapper.map { raise Core::Test::Result::Skipped, "dry run" }
233
- end
234
- end
235
- end
236
-
237
- end
238
- end