cucumber 2.0.0.beta.3 → 2.0.0.beta.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +20 -3
  3. data/cucumber.gemspec +2 -1
  4. data/examples/tcl/features/step_definitions/fib_steps.rb +1 -1
  5. data/features/docs/extending_cucumber/custom_formatter.feature +65 -7
  6. data/features/docs/formatters/debug_formatter.feature +24 -17
  7. data/features/docs/formatters/pretty_formatter.feature +42 -0
  8. data/features/docs/formatters/rerun_formatter.feature +3 -2
  9. data/lib/cucumber/cli/configuration.rb +3 -7
  10. data/lib/cucumber/cli/main.rb +1 -1
  11. data/lib/cucumber/{runtime → filters}/gated_receiver.rb +5 -1
  12. data/lib/cucumber/filters/quit.rb +24 -0
  13. data/lib/cucumber/filters/randomizer.rb +36 -0
  14. data/lib/cucumber/filters/tag_limits.rb +40 -0
  15. data/lib/cucumber/{runtime → filters}/tag_limits/test_case_index.rb +4 -2
  16. data/lib/cucumber/{runtime → filters}/tag_limits/verifier.rb +4 -2
  17. data/lib/cucumber/formatter/console.rb +2 -2
  18. data/lib/cucumber/formatter/debug.rb +1 -8
  19. data/lib/cucumber/formatter/fanout.rb +27 -0
  20. data/lib/cucumber/formatter/gherkin_formatter_adapter.rb +1 -3
  21. data/lib/cucumber/formatter/html.rb +12 -4
  22. data/lib/cucumber/formatter/ignore_missing_messages.rb +20 -0
  23. data/lib/cucumber/formatter/junit.rb +2 -2
  24. data/lib/cucumber/formatter/legacy_api/adapter.rb +1008 -0
  25. data/lib/cucumber/formatter/legacy_api/ast.rb +374 -0
  26. data/lib/cucumber/formatter/legacy_api/results.rb +51 -0
  27. data/lib/cucumber/formatter/legacy_api/runtime_facade.rb +30 -0
  28. data/lib/cucumber/formatter/pretty.rb +4 -0
  29. data/lib/cucumber/formatter/rerun.rb +14 -88
  30. data/lib/cucumber/language_support/language_methods.rb +0 -54
  31. data/lib/cucumber/multiline_argument/data_table.rb +3 -4
  32. data/lib/cucumber/platform.rb +1 -1
  33. data/lib/cucumber/runtime.rb +41 -107
  34. data/spec/cucumber/{runtime → filters}/gated_receiver_spec.rb +3 -3
  35. data/spec/cucumber/{runtime → filters}/tag_limits/test_case_index_spec.rb +3 -3
  36. data/spec/cucumber/{runtime → filters}/tag_limits/verifier_spec.rb +4 -4
  37. data/spec/cucumber/{runtime/tag_limits/filter_spec.rb → filters/tag_limits_spec.rb} +6 -6
  38. data/spec/cucumber/formatter/debug_spec.rb +39 -530
  39. data/spec/cucumber/formatter/html_spec.rb +56 -0
  40. data/spec/cucumber/formatter/legacy_api/adapter_spec.rb +1902 -0
  41. data/spec/cucumber/formatter/pretty_spec.rb +128 -0
  42. data/spec/cucumber/formatter/rerun_spec.rb +106 -0
  43. data/spec/cucumber/formatter/spec_helper.rb +6 -2
  44. data/spec/cucumber/rb_support/rb_language_spec.rb +2 -2
  45. data/spec/cucumber/rb_support/rb_step_definition_spec.rb +1 -1
  46. data/spec/cucumber/runtime_spec.rb +1 -5
  47. data/spec/spec_helper.rb +2 -0
  48. metadata +44 -29
  49. data/features/docs/extending_cucumber/formatter_callbacks.feature +0 -370
  50. data/features/docs/output_from_hooks.feature +0 -128
  51. data/lib/cucumber/reports/legacy_formatter.rb +0 -1349
  52. data/lib/cucumber/runtime/results.rb +0 -64
  53. data/lib/cucumber/runtime/tag_limits.rb +0 -15
  54. data/lib/cucumber/runtime/tag_limits/filter.rb +0 -31
  55. data/spec/cucumber/reports/legacy_formatter_spec.rb +0 -1860
  56. data/spec/cucumber/runtime/results_spec.rb +0 -88
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1b115e5b0a7ae23e6b0372462a320314ee144811
4
- data.tar.gz: 3143905ef42ea795c85cc6163dedf95bd670f582
3
+ metadata.gz: 4eb48e6463061c8e32ec4f37449eaf5d11d36071
4
+ data.tar.gz: 2eda62607c7d63399d30630949a593c8d7c943c0
5
5
  SHA512:
6
- metadata.gz: 1144b0d0bdf707e16db0b4d389aa7242f870df050db0da4ffe6c749e26309dfbd0bec80eb3db5995c27456e8cddd610bcb242d4a407a3a5887a0933c510e2744
7
- data.tar.gz: dcfa6d1ca0b6af5abb794495a6872509976519c40af52075f78056593dfde8d397e10ae7d67ae3f2aa710ac2a6401aaca6c481747033d38d8d35c911f20acb08
6
+ metadata.gz: 03dfce34351bcf81c2093668854a166f9679c3d59dfb5cc4535034ad008f64a2aae140ecfed9dabfe2207b4b305f2831b9208797c9f929ed5defaadc8dff8c49
7
+ data.tar.gz: ee606fff52a8ceecb2802e4feff9f64043746a7741317a4de32cf04fc22420d6425bf033c46961daeb4d42e12dfba722628e9e82752b7dd2857ce2074cedbe3b
data/History.md CHANGED
@@ -1,4 +1,21 @@
1
- ## [In Git](https://github.com/cucumber/cucumber/compare/v.2.0.0.beta.2...master)
1
+ ## [In Git](https://github.com/cucumber/cucumber/compare/v2.0.0.beta.4...master)
2
+
3
+ ## [v2.0.0.beta.4](https://github.com/cucumber/cucumber/compare/v2.0.0.beta.3...v2.0.0.beta.4)
4
+ ### New Features
5
+
6
+ * Support both new and legacy formatter APIs simultaneously (@mattwynne and @tooky)
7
+
8
+ ### Bugfixes
9
+
10
+ * Localize the Scenario keyword with the --expand option ([766](https://github.com/cucumber/cucumber/pull/766) @brasmusson)
11
+ * Handle hook output appropriately in the HTML formatter ([746](https://github.com/cucumber/cucumber/pull/746), [731](https://github.com/cucumber/cucumber/issues/731), [298](https://github.com/cucumber/cucumber/pull/298) @brasmusson)
12
+ * Handle hook output appropriately in the Pretty formatter ([738](https://github.com/cucumber/cucumber/pull/738) @brasmusson)
13
+
14
+ ### Internal changes
15
+
16
+ * Re-write rerun formatter against new formatter API
17
+
18
+ ## [v2.0.0.beta.3](https://github.com/cucumber/cucumber/compare/v2.0.0.beta.2...v2.0.0.beta.3)
2
19
 
3
20
  ### Removed Features
4
21
 
@@ -18,14 +35,14 @@
18
35
  * Add back support for the DataTable API ([729](https://github.com/cucumber/cucumber/pull/729) @mattwynne and @tooky)
19
36
  * Fix Windows support loading files properly ([739](https://github.com/cucumber/cucumber/issues/739) @os97673)
20
37
 
21
- ## [v2.0.0.beta.2](https://github.com/cucumber/cucumber/compare/v.2.0.0.beta.1...v.2.0.0.beta.2)
38
+ ## [v2.0.0.beta.2](https://github.com/cucumber/cucumber/compare/v2.0.0.beta.1...v2.0.0.beta.2)
22
39
 
23
40
  ### Bugfixes
24
41
 
25
42
  * Better reporting of exceptions in Before / After hooks ([723](https://github.com/cucumber/cucumber/pull/723) @mattwynne)
26
43
  * Add `#source_tag_names` method to `TestCase` object passed to hooks (@mattwynne)
27
44
 
28
- ## [v2.0.0.beta.1 ](https://github.com/cucumber/cucumber/compare/v1.3.8...v.2.0.0.beta.1)
45
+ ## [v2.0.0.beta.1 ](https://github.com/cucumber/cucumber/compare/v1.3.8...v2.0.0.beta.1)
29
46
 
30
47
  Version 2.0 contains a major internal redesign, extracting the core logic of
31
48
  parsing and executing tests into a [separate gem](https://github.com/cucumber/cucumber-ruby-core).
data/cucumber.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.add_dependency 'multi_json', '>= 1.7.5', '< 2.0'
22
22
  s.add_dependency 'multi_test', '>= 0.1.1'
23
23
 
24
- s.add_development_dependency 'aruba', '~> 0.5.3'
24
+ s.add_development_dependency 'aruba', '~> 0.6.1'
25
25
  s.add_development_dependency 'json', '~> 1.7'
26
26
  s.add_development_dependency 'nokogiri', '~> 1.5'
27
27
  s.add_development_dependency 'rake', '>= 0.9.2'
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
29
29
  s.add_development_dependency 'simplecov', '>= 0.6.2'
30
30
  s.add_development_dependency 'coveralls', '~> 0.7'
31
31
  s.add_development_dependency 'syntax', '>= 1.0.0'
32
+ s.add_development_dependency 'pry'
32
33
 
33
34
  # For Documentation:
34
35
  s.add_development_dependency 'bcat', '~> 0.6.2'
@@ -3,5 +3,5 @@ When /^I ask Tcl to calculate fibonacci for (\d+)$/ do |n|
3
3
  end
4
4
 
5
5
  Then /^it should give me (\d+)$/ do |expected|
6
- @fib_result.should == expected.to_i
6
+ expect(@fib_result).to eq expected.to_i
7
7
  end
@@ -1,18 +1,45 @@
1
1
  Feature: Custom Formatter
2
2
 
3
- Scenario: my own formatter
3
+ Background:
4
4
  Given a file named "features/f.feature" with:
5
5
  """
6
6
  Feature: I'll use my own
7
- because I'm worth it
8
- Scenario: just print me
7
+ Scenario: Just print me
9
8
  Given this step passes
10
9
  """
11
10
  And the standard step definitions
12
- And a file named "features/support/ze/formator.rb" with:
11
+
12
+ Scenario: Use the new API
13
+ Given a file named "features/support/custom_formatter.rb" with:
13
14
  """
14
- module Ze
15
- class Formator
15
+ module MyCustom
16
+ class Formatter
17
+ def initialize(runtime, io, options)
18
+ @io = io
19
+ end
20
+
21
+ def before_test_case(test_case)
22
+ feature = test_case.source.first
23
+ scenario = test_case.source.last
24
+ @io.puts feature.short_name.upcase
25
+ @io.puts " #{scenario.name.upcase}"
26
+ end
27
+ end
28
+ end
29
+ """
30
+ When I run `cucumber features/f.feature --format MyCustom::Formatter`
31
+ Then it should pass with exactly:
32
+ """
33
+ I'LL USE MY OWN
34
+ JUST PRINT ME
35
+
36
+ """
37
+
38
+ Scenario: Use the legacy API
39
+ Given a file named "features/support/custom_legacy_formatter.rb" with:
40
+ """
41
+ module MyCustom
42
+ class LegacyFormatter
16
43
  def initialize(runtime, io, options)
17
44
  @io = io
18
45
  end
@@ -27,7 +54,38 @@ Feature: Custom Formatter
27
54
  end
28
55
  end
29
56
  """
30
- When I run `cucumber features/f.feature --format Ze::Formator`
57
+ When I run `cucumber features/f.feature --format MyCustom::LegacyFormatter`
58
+ Then it should pass with exactly:
59
+ """
60
+ I'LL USE MY OWN
61
+ JUST PRINT ME
62
+
63
+ """
64
+
65
+ Scenario: Use both
66
+ You can use a specific shim to opt-in to both APIs at once.
67
+
68
+ Given a file named "features/support/custom_mixed_formatter.rb" with:
69
+ """
70
+ module MyCustom
71
+ class MixedFormatter
72
+
73
+ def initialize(runtime, io, options)
74
+ @io = io
75
+ end
76
+
77
+ def before_test_case(test_case)
78
+ feature = test_case.source.first
79
+ @io.puts feature.short_name.upcase
80
+ end
81
+
82
+ def scenario_name(keyword, name, file_colon_line, source_indent)
83
+ @io.puts " #{name.upcase}"
84
+ end
85
+ end
86
+ end
87
+ """
88
+ When I run `cucumber features/f.feature --format MyCustom::MixedFormatter`
31
89
  Then it should pass with exactly:
32
90
  """
33
91
  I'LL USE MY OWN
@@ -18,23 +18,30 @@ Feature: Debug formatter
18
18
  Then the stderr should not contain anything
19
19
  Then it should pass with:
20
20
  """
21
+ before_test_case
21
22
  before_features
22
- before_feature
23
- before_tags
24
- after_tags
25
- feature_name
26
- before_feature_element
27
- before_tags
28
- after_tags
29
- scenario_name
30
- before_steps
31
- before_step
32
- before_step_result
33
- step_name
34
- after_step_result
35
- after_step
36
- after_steps
37
- after_feature_element
38
- after_feature
23
+ before_feature
24
+ before_tags
25
+ after_tags
26
+ feature_name
27
+ before_test_step
28
+ after_test_step
29
+ before_test_step
30
+ before_feature_element
31
+ before_tags
32
+ after_tags
33
+ scenario_name
34
+ before_steps
35
+ before_step
36
+ before_step_result
37
+ step_name
38
+ after_step_result
39
+ after_step
40
+ after_test_step
41
+ after_steps
42
+ after_feature_element
43
+ after_test_case
44
+ after_feature
39
45
  after_features
46
+ done
40
47
  """
@@ -28,4 +28,46 @@ Feature: Pretty output formatter
28
28
  """
29
29
  Using the default profile...
30
30
  """
31
+ Scenario: Hook output should be printed before hook exception
32
+ Given the standard step definitions
33
+ And a file named "features/test.feature" with:
34
+ """
35
+ Feature:
36
+ Scenario:
37
+ Given this step passes
38
+ """
39
+ And a file named "features/step_definitions/output_steps.rb" with:
40
+ """
41
+ Before do
42
+ puts "Before hook"
43
+ end
31
44
 
45
+ AfterStep do
46
+ puts "AfterStep hook"
47
+ end
48
+
49
+ After do
50
+ puts "After hook"
51
+ raise "error"
52
+ end
53
+ """
54
+ When I run `cucumber -q -f pretty features/test.feature`
55
+ Then the stderr should not contain anything
56
+ Then it should fail with:
57
+ """
58
+ Feature:
59
+
60
+ Scenario:
61
+ Before hook
62
+ Given this step passes
63
+ AfterStep hook
64
+ After hook
65
+ error (RuntimeError)
66
+ ./features/step_definitions/output_steps.rb:11:in `After'
67
+
68
+ Failing Scenarios:
69
+ cucumber features/test.feature:2
70
+
71
+ 1 scenario (1 failed)
72
+ 1 step (1 passed)
73
+ """
@@ -113,8 +113,9 @@ Feature: Rerun formatter
113
113
  features/failing_background_outline.feature:11:12
114
114
  """
115
115
 
116
- Scenario: Scenario outlines with expand
117
- For details see https://github.com/cucumber/cucumber/issues/503
116
+ Scenario: Scenario outlines with expand
117
+ For details see https://github.com/cucumber/cucumber/issues/503
118
+
118
119
  Given a file named "features/one_passing_one_failing.feature" with:
119
120
  """
120
121
  Feature: One passing example, one failing example
@@ -66,10 +66,6 @@ module Cucumber
66
66
  @options[:snippet_type] || :regexp
67
67
  end
68
68
 
69
- def build_tree_walker(runtime)
70
- Ast::TreeWalker.new(runtime, formatters(runtime), self)
71
- end
72
-
73
69
  def formatter_class(format)
74
70
  if(builtin = Options::BUILTIN_FORMATS[format])
75
71
  constantize(builtin[0])
@@ -169,13 +165,13 @@ module Cucumber
169
165
  @options[:paths]
170
166
  end
171
167
 
172
- def formatters(runtime)
168
+ def formatter_factories
173
169
  @options[:formats].map do |format_and_out|
174
170
  format = format_and_out[0]
175
171
  path_or_io = format_and_out[1]
176
172
  begin
177
- formatter_class = formatter_class(format)
178
- formatter_class.new(runtime, path_or_io, @options)
173
+ factory = formatter_class(format)
174
+ yield factory, path_or_io, @options
179
175
  rescue Exception => e
180
176
  e.message << "\nError creating formatter: #{format}"
181
177
  raise e
@@ -36,7 +36,7 @@ module Cucumber
36
36
  end
37
37
 
38
38
  runtime.run!
39
- failure = runtime.results.failure? || Cucumber.wants_to_quit
39
+ failure = runtime.failure? || Cucumber.wants_to_quit
40
40
  @kernel.exit(failure ? 1 : 0)
41
41
  rescue FileNotFoundException => e
42
42
  @err.puts(e.message)
@@ -1,5 +1,6 @@
1
1
  module Cucumber
2
- class Runtime
2
+ module Filters
3
+
3
4
  class GatedReceiver
4
5
  def initialize(receiver)
5
6
  @receiver = receiver
@@ -8,6 +9,7 @@ module Cucumber
8
9
 
9
10
  def test_case(test_case)
10
11
  @test_cases << test_case
12
+ self
11
13
  end
12
14
 
13
15
  def done
@@ -15,7 +17,9 @@ module Cucumber
15
17
  test_case.describe_to(@receiver)
16
18
  end
17
19
  @receiver.done
20
+ self
18
21
  end
19
22
  end
23
+
20
24
  end
21
25
  end
@@ -0,0 +1,24 @@
1
+ module Cucumber
2
+ module Filters
3
+
4
+ class Quit
5
+ def initialize(receiver)
6
+ @receiver = receiver
7
+ end
8
+
9
+ def test_case(test_case)
10
+ unless Cucumber.wants_to_quit
11
+ test_case.describe_to @receiver
12
+ end
13
+ self
14
+ end
15
+
16
+ def done
17
+ @receiver.done
18
+ self
19
+ end
20
+ end
21
+
22
+ end
23
+ end
24
+
@@ -0,0 +1,36 @@
1
+ module Cucumber
2
+ module Filters
3
+
4
+ # Batches up all test cases, randomizes them, and then sends them on
5
+ class Randomizer
6
+ def initialize(seed, receiver)
7
+ @receiver = receiver
8
+ @test_cases = []
9
+ @seed = seed
10
+ end
11
+
12
+ def test_case(test_case)
13
+ @test_cases << test_case
14
+ self
15
+ end
16
+
17
+ def done
18
+ shuffled_test_cases.each do |test_case|
19
+ test_case.describe_to(@receiver)
20
+ end
21
+ @receiver.done
22
+ self
23
+ end
24
+
25
+ private
26
+
27
+ def shuffled_test_cases
28
+ @test_cases.shuffle(random: Random.new(seed))
29
+ end
30
+
31
+ attr_reader :seed
32
+ private :seed
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,40 @@
1
+ require "cucumber/filters/gated_receiver"
2
+ require "cucumber/filters/tag_limits/test_case_index"
3
+ require "cucumber/filters/tag_limits/verifier"
4
+
5
+ module Cucumber
6
+ module Filters
7
+ class TagLimitExceededError < StandardError
8
+ def initialize(*limit_breaches)
9
+ super(limit_breaches.map(&:to_s).join("\n"))
10
+ end
11
+ end
12
+
13
+ class TagLimits
14
+ def initialize(tag_limits, receiver)
15
+ @gated_receiver = GatedReceiver.new(receiver)
16
+ @test_case_index = TestCaseIndex.new
17
+ @verifier = Verifier.new(tag_limits)
18
+ end
19
+
20
+ def test_case(test_case)
21
+ gated_receiver.test_case(test_case)
22
+ test_case_index.add(test_case)
23
+ self
24
+ end
25
+
26
+ def done
27
+ verifier.verify!(test_case_index)
28
+ gated_receiver.done
29
+ self
30
+ end
31
+
32
+ private
33
+
34
+ attr_reader :gated_receiver
35
+ attr_reader :test_case_index
36
+ attr_reader :verifier
37
+ end
38
+
39
+ end
40
+ end