cucumber 3.1.0 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +38 -2
  3. data/CONTRIBUTING.md +1 -0
  4. data/README.md +6 -7
  5. data/lib/autotest/cucumber.rb +1 -0
  6. data/lib/autotest/cucumber_mixin.rb +1 -0
  7. data/lib/autotest/cucumber_rails.rb +1 -0
  8. data/lib/autotest/cucumber_rails_rspec.rb +1 -0
  9. data/lib/autotest/cucumber_rails_rspec2.rb +1 -0
  10. data/lib/autotest/cucumber_rspec.rb +1 -0
  11. data/lib/autotest/cucumber_rspec2.rb +1 -0
  12. data/lib/autotest/discover.rb +1 -0
  13. data/lib/cucumber.rb +1 -0
  14. data/lib/cucumber/cli/configuration.rb +1 -0
  15. data/lib/cucumber/cli/main.rb +2 -2
  16. data/lib/cucumber/cli/options.rb +42 -40
  17. data/lib/cucumber/cli/profile_loader.rb +5 -7
  18. data/lib/cucumber/cli/rerun_file.rb +1 -0
  19. data/lib/cucumber/configuration.rb +1 -0
  20. data/lib/cucumber/constantize.rb +6 -5
  21. data/lib/cucumber/core_ext/string.rb +1 -0
  22. data/lib/cucumber/deprecate.rb +1 -1
  23. data/lib/cucumber/encoding.rb +2 -1
  24. data/lib/cucumber/errors.rb +1 -0
  25. data/lib/cucumber/events.rb +1 -1
  26. data/lib/cucumber/events/gherkin_source_read.rb +1 -4
  27. data/lib/cucumber/events/step_activated.rb +4 -5
  28. data/lib/cucumber/events/step_definition_registered.rb +4 -8
  29. data/lib/cucumber/events/test_case_finished.rb +0 -4
  30. data/lib/cucumber/events/test_case_started.rb +0 -4
  31. data/lib/cucumber/events/test_run_finished.rb +2 -3
  32. data/lib/cucumber/events/test_run_started.rb +2 -4
  33. data/lib/cucumber/events/test_step_finished.rb +0 -4
  34. data/lib/cucumber/events/test_step_started.rb +1 -5
  35. data/lib/cucumber/file_specs.rb +2 -1
  36. data/lib/cucumber/filters.rb +1 -0
  37. data/lib/cucumber/filters/activate_steps.rb +1 -1
  38. data/lib/cucumber/filters/apply_after_hooks.rb +1 -0
  39. data/lib/cucumber/filters/apply_after_step_hooks.rb +1 -0
  40. data/lib/cucumber/filters/apply_around_hooks.rb +1 -0
  41. data/lib/cucumber/filters/apply_before_hooks.rb +1 -0
  42. data/lib/cucumber/filters/broadcast_test_run_started_event.rb +2 -1
  43. data/lib/cucumber/filters/gated_receiver.rb +1 -2
  44. data/lib/cucumber/filters/prepare_world.rb +2 -5
  45. data/lib/cucumber/filters/quit.rb +2 -3
  46. data/lib/cucumber/filters/randomizer.rb +6 -7
  47. data/lib/cucumber/filters/retry.rb +2 -2
  48. data/lib/cucumber/filters/tag_limits.rb +2 -2
  49. data/lib/cucumber/filters/tag_limits/test_case_index.rb +1 -2
  50. data/lib/cucumber/filters/tag_limits/verifier.rb +1 -2
  51. data/lib/cucumber/formatter/ansicolor.rb +13 -12
  52. data/lib/cucumber/formatter/backtrace_filter.rb +1 -2
  53. data/lib/cucumber/formatter/console.rb +10 -11
  54. data/lib/cucumber/formatter/console_counts.rb +4 -4
  55. data/lib/cucumber/formatter/console_issues.rb +3 -3
  56. data/lib/cucumber/formatter/duration.rb +1 -0
  57. data/lib/cucumber/formatter/duration_extractor.rb +1 -1
  58. data/lib/cucumber/formatter/fail_fast.rb +9 -6
  59. data/lib/cucumber/formatter/fanout.rb +1 -3
  60. data/lib/cucumber/formatter/hook_query_visitor.rb +1 -0
  61. data/lib/cucumber/formatter/html.rb +27 -31
  62. data/lib/cucumber/formatter/html_builder.rb +2 -1
  63. data/lib/cucumber/formatter/ignore_missing_messages.rb +1 -2
  64. data/lib/cucumber/formatter/interceptor.rb +18 -5
  65. data/lib/cucumber/formatter/io.rb +1 -0
  66. data/lib/cucumber/formatter/json.rb +2 -1
  67. data/lib/cucumber/formatter/json_pretty.rb +1 -0
  68. data/lib/cucumber/formatter/junit.rb +16 -15
  69. data/lib/cucumber/formatter/pretty.rb +3 -2
  70. data/lib/cucumber/formatter/progress.rb +3 -2
  71. data/lib/cucumber/formatter/rerun.rb +1 -0
  72. data/lib/cucumber/formatter/stepdefs.rb +1 -0
  73. data/lib/cucumber/formatter/steps.rb +2 -2
  74. data/lib/cucumber/formatter/summary.rb +1 -1
  75. data/lib/cucumber/formatter/unicode.rb +2 -2
  76. data/lib/cucumber/formatter/usage.rb +21 -18
  77. data/lib/cucumber/gherkin/data_table_parser.rb +1 -0
  78. data/lib/cucumber/gherkin/formatter/ansi_escapes.rb +86 -85
  79. data/lib/cucumber/gherkin/formatter/escaping.rb +13 -12
  80. data/lib/cucumber/gherkin/i18n.rb +1 -0
  81. data/lib/cucumber/gherkin/steps_parser.rb +1 -0
  82. data/lib/cucumber/glue/dsl.rb +1 -0
  83. data/lib/cucumber/glue/hook.rb +1 -0
  84. data/lib/cucumber/glue/invoke_in_world.rb +3 -3
  85. data/lib/cucumber/glue/proto_world.rb +8 -9
  86. data/lib/cucumber/glue/registry_and_more.rb +13 -12
  87. data/lib/cucumber/glue/snippet.rb +1 -5
  88. data/lib/cucumber/glue/step_definition.rb +9 -9
  89. data/lib/cucumber/glue/world_factory.rb +0 -2
  90. data/lib/cucumber/hooks.rb +1 -3
  91. data/lib/cucumber/load_path.rb +1 -0
  92. data/lib/cucumber/multiline_argument.rb +2 -2
  93. data/lib/cucumber/multiline_argument/data_table.rb +10 -10
  94. data/lib/cucumber/multiline_argument/data_table/diff_matrices.rb +4 -7
  95. data/lib/cucumber/multiline_argument/doc_string.rb +1 -0
  96. data/lib/cucumber/platform.rb +2 -1
  97. data/lib/cucumber/project_initializer.rb +1 -1
  98. data/lib/cucumber/rake/task.rb +7 -4
  99. data/lib/cucumber/rspec/disable_option_parser.rb +1 -0
  100. data/lib/cucumber/rspec/doubles.rb +1 -0
  101. data/lib/cucumber/running_test_case.rb +2 -1
  102. data/lib/cucumber/runtime.rb +5 -5
  103. data/lib/cucumber/runtime/after_hooks.rb +1 -0
  104. data/lib/cucumber/runtime/before_hooks.rb +1 -0
  105. data/lib/cucumber/runtime/for_programming_languages.rb +8 -7
  106. data/lib/cucumber/runtime/step_hooks.rb +2 -0
  107. data/lib/cucumber/runtime/support_code.rb +3 -7
  108. data/lib/cucumber/runtime/user_interface.rb +2 -3
  109. data/lib/cucumber/step_argument.rb +1 -0
  110. data/lib/cucumber/step_definition_light.rb +2 -1
  111. data/lib/cucumber/step_definitions.rb +1 -0
  112. data/lib/cucumber/step_match.rb +5 -7
  113. data/lib/cucumber/step_match_search.rb +1 -2
  114. data/lib/cucumber/term/ansicolor.rb +30 -30
  115. data/lib/cucumber/unit.rb +1 -0
  116. data/lib/cucumber/version +1 -1
  117. data/lib/simplecov_setup.rb +1 -0
  118. metadata +61 -117
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Cucumber
3
4
  module Cli
4
5
  class RerunFile
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'cucumber/constantize'
3
4
  require 'cucumber/cli/rerun_file'
4
5
  require 'cucumber/events'
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'cucumber/platform'
3
4
  module Cucumber
4
5
  module Constantize #:nodoc:
@@ -26,11 +27,11 @@ module Cucumber
26
27
 
27
28
  # Snagged from active_support
28
29
  def underscore(camel_cased_word)
29
- camel_cased_word.to_s.gsub(/::/, '/').
30
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
31
- gsub(/([a-z\d])([A-Z])/,'\1_\2').
32
- tr('-', '_').
33
- downcase
30
+ camel_cased_word.to_s.gsub(/::/, '/')
31
+ .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
32
+ .gsub(/([a-z\d])([A-Z])/, '\1_\2')
33
+ .tr('-', '_')
34
+ .downcase
34
35
  end
35
36
 
36
37
  private
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class String #:nodoc:
3
4
  def indent(n)
4
5
  if n >= 0
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'cucumber/platform'
3
4
  require 'cucumber/gherkin/formatter/ansi_escapes'
4
5
 
@@ -26,5 +27,4 @@ module Cucumber
26
27
  def self.deprecate(*args)
27
28
  Deprecate::STRATEGY.call(*args)
28
29
  end
29
-
30
30
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
- # See https://github.com/cucumber/cucumber/issues/693
2
+
3
+ # See https://github.com/cucumber/cucumber/issues/693
3
4
  if defined? Encoding
4
5
  Encoding.default_external = 'utf-8'
5
6
  Encoding.default_internal = 'utf-8'
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'cucumber/core/test/result'
3
4
 
4
5
  module Cucumber
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  Dir[File.dirname(__FILE__) + '/events/*.rb'].map(&method(:require))
3
4
 
4
5
  module Cucumber
5
-
6
6
  # Events tell you what's happening while Cucumber runs your features.
7
7
  #
8
8
  # They're designed to be read-only, appropriate for writing formatters and other
@@ -2,16 +2,13 @@ require 'cucumber/core/events'
2
2
 
3
3
  module Cucumber
4
4
  module Events
5
-
6
- # Fired after we've read in the contents of a feature file
5
+ # Fired after we've read in the contents of a feature file
7
6
  class GherkinSourceRead < Core::Event.new(:path, :body)
8
-
9
7
  # The path to the file
10
8
  attr_reader :path
11
9
 
12
10
  # The raw Gherkin source
13
11
  attr_reader :body
14
12
  end
15
-
16
13
  end
17
14
  end
@@ -1,23 +1,22 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'cucumber/core/events'
3
4
 
4
5
  module Cucumber
5
6
  module Events
6
-
7
7
  # Event fired when a step is activated
8
8
  class StepActivated < Core::Event.new(:test_step, :step_match)
9
-
10
- # The test step that was matched.
9
+ # The test step that was matched.
11
10
  #
12
11
  # @return [Cucumber::Core::Test::Step]
13
12
  attr_reader :test_step
14
13
 
15
- # Information about the matching definition.
14
+ # Information about the matching definition.
16
15
  #
17
16
  # @return [Cucumber::StepMatch]
18
17
  attr_reader :step_match
19
18
 
20
- # @private
19
+ # @private
21
20
  def initialize(test_step, step_match)
22
21
  @test_step, @step_match = test_step, step_match
23
22
  end
@@ -1,24 +1,20 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'cucumber/core/events'
3
4
 
4
5
  module Cucumber
5
6
  module Events
6
-
7
- # Event fired after each step definition has been registered
7
+ # Event fired after each step definition has been registered
8
8
  class StepDefinitionRegistered < Core::Event.new(:step_definition)
9
-
10
-
11
- #_The step definition that was just registered.
9
+ # The step definition that was just registered.
12
10
  #
13
11
  # @return [RbSupport::RbStepDefinition]
14
12
  attr_reader :step_definition
15
13
 
16
- #_@private
14
+ # _@private
17
15
  def initialize(step_definition)
18
16
  @step_definition = step_definition
19
17
  end
20
-
21
18
  end
22
-
23
19
  end
24
20
  end
@@ -2,17 +2,13 @@ require 'cucumber/core/events'
2
2
 
3
3
  module Cucumber
4
4
  module Events
5
-
6
5
  # Signals that a {Cucumber::Core::Test::Case} has finished executing
7
6
  class TestCaseFinished < Core::Events::TestCaseFinished
8
-
9
7
  # @return [Cucumber::Core::Test::Case] that was executed
10
8
  attr_reader :test_case
11
9
 
12
10
  # @return [Cucumber::Core::Test::Result] the result of running the {Cucumber::Core::Test::Case}
13
11
  attr_reader :result
14
-
15
12
  end
16
-
17
13
  end
18
14
  end
@@ -2,14 +2,10 @@ require 'cucumber/core/events'
2
2
 
3
3
  module Cucumber
4
4
  module Events
5
-
6
5
  # Signals that a {Cucumber::Core::Test::Case} is about to be executed
7
6
  class TestCaseStarted < Core::Events::TestCaseStarted
8
-
9
7
  # @return [Cucumber::Core::Test::Case] the test case to be executed
10
8
  attr_reader :test_case
11
-
12
9
  end
13
-
14
10
  end
15
11
  end
@@ -1,12 +1,11 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'cucumber/core/events'
3
4
 
4
5
  module Cucumber
5
6
  module Events
6
-
7
- # Event fired after all test cases have finished executing
7
+ # Event fired after all test cases have finished executing
8
8
  class TestRunFinished < Core::Event.new
9
9
  end
10
-
11
10
  end
12
11
  end
@@ -1,16 +1,14 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'cucumber/core/events'
3
4
 
4
5
  module Cucumber
5
6
  module Events
6
-
7
- # Event fired once all test cases have been filtered before
7
+ # Event fired once all test cases have been filtered before
8
8
  # the first one is executed.
9
9
  class TestRunStarted < Core::Event.new(:test_cases)
10
-
11
10
  # @return [Array<Cucumber::Core::Test::Case>] the test cases to be executed
12
11
  attr_reader :test_cases
13
12
  end
14
-
15
13
  end
16
14
  end
@@ -2,17 +2,13 @@ require 'cucumber/core/events'
2
2
 
3
3
  module Cucumber
4
4
  module Events
5
-
6
5
  # Signals that a {Cucumber::Core::Test::Step} has finished executing
7
6
  class TestStepFinished < Core::Events::TestStepFinished
8
-
9
7
  # @return [Cucumber::Core::Test::Step] the test step that was executed
10
8
  attr_reader :test_step
11
9
 
12
10
  # @return [Cucumber::Core::Test::Result] the result of running the {Cucumber::Core::Test::Step}
13
11
  attr_reader :result
14
-
15
12
  end
16
-
17
13
  end
18
14
  end
@@ -2,14 +2,10 @@ require 'cucumber/core/events'
2
2
 
3
3
  module Cucumber
4
4
  module Events
5
-
6
- # Signals that a {Cucumber::Core::Test::Step} is about to be executed
5
+ # Signals that a {Cucumber::Core::Test::Step} is about to be executed
7
6
  class TestStepStarted < Core::Events::TestStepStarted
8
-
9
7
  # @return [Cucumber::Core::Test::Step] the test step to be executed
10
8
  attr_reader :test_step
11
-
12
9
  end
13
-
14
10
  end
15
11
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'cucumber'
3
4
  require 'cucumber/core/ast/location'
4
5
 
@@ -30,7 +31,7 @@ module Cucumber
30
31
  attr_reader :file
31
32
 
32
33
  def locations
33
- return [ Core::Ast::Location.new(@file) ] if @lines.empty?
34
+ return [Core::Ast::Location.new(@file)] if @lines.empty?
34
35
  @lines.map { |line| Core::Ast::Location.new(@file, line) }
35
36
  end
36
37
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'cucumber/filters/activate_steps'
3
4
  require 'cucumber/filters/apply_after_step_hooks'
4
5
  require 'cucumber/filters/apply_before_hooks'
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'cucumber/core/filter'
3
4
  require 'cucumber/step_match'
4
5
  require 'cucumber/events'
@@ -7,7 +8,6 @@ require 'cucumber/errors'
7
8
  module Cucumber
8
9
  module Filters
9
10
  class ActivateSteps < Core::Filter.new(:step_match_search, :configuration)
10
-
11
11
  def test_case(test_case)
12
12
  CaseFilter.new(test_case, step_match_search, configuration).test_case.describe_to receiver
13
13
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Cucumber
3
4
  module Filters
4
5
  class ApplyAfterHooks < Core::Filter.new(:hooks)
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'cucumber/core/filter'
3
4
 
4
5
  module Cucumber
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'cucumber/core/filter'
3
4
 
4
5
  module Cucumber
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Cucumber
3
4
  module Filters
4
5
  class ApplyBeforeHooks < Core::Filter.new(:hooks)
@@ -1,10 +1,11 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Cucumber
3
4
  module Filters
4
5
  # Added at the end of the filter chain to broadcast a list of
5
6
  # all of the test cases that have made it through the filters.
6
7
  class BroadcastTestRunStartedEvent < Core::Filter.new(:config)
7
- def initialize(config, receiver=nil)
8
+ def initialize(config, receiver = nil)
8
9
  super
9
10
  @test_cases = []
10
11
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Cucumber
3
4
  module Filters
4
-
5
5
  class GatedReceiver
6
6
  def initialize(receiver)
7
7
  @receiver = receiver
@@ -21,6 +21,5 @@ module Cucumber
21
21
  self
22
22
  end
23
23
  end
24
-
25
24
  end
26
25
  end
@@ -1,13 +1,12 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'cucumber/core/filter'
3
4
  require 'cucumber/core/ast/location'
4
5
  require 'cucumber/running_test_case'
5
6
 
6
7
  module Cucumber
7
8
  module Filters
8
-
9
9
  class PrepareWorld < Core::Filter.new(:runtime)
10
-
11
10
  def test_case(test_case)
12
11
  CaseFilter.new(runtime, test_case).test_case.describe_to receiver
13
12
  end
@@ -25,7 +24,7 @@ module Cucumber
25
24
  end
26
25
  around_hooks = [init_scenario] + @original_test_case.around_hooks
27
26
 
28
- empty_hook = proc {} #no op - legacy format adapter expects a before hooks
27
+ empty_hook = proc {} # no op - legacy format adapter expects a before hooks
29
28
  empty_hook_location = Cucumber::Core::Ast::Location.from_source_location(*empty_hook.source_location)
30
29
  default_hook = Cucumber::Hooks.before_hook(@original_test_case.source, empty_hook_location, &empty_hook)
31
30
  steps = [default_hook] + @original_test_case.test_steps
@@ -39,8 +38,6 @@ module Cucumber
39
38
  @scenario ||= RunningTestCase.new(test_case)
40
39
  end
41
40
  end
42
-
43
41
  end
44
-
45
42
  end
46
43
  end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Cucumber
3
4
  module Filters
4
-
5
5
  class Quit
6
- def initialize(receiver=nil)
6
+ def initialize(receiver = nil)
7
7
  @receiver = receiver
8
8
  end
9
9
 
@@ -23,6 +23,5 @@ module Cucumber
23
23
  self.class.new(receiver)
24
24
  end
25
25
  end
26
-
27
26
  end
28
27
  end
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'digest/sha2'
3
4
 
4
5
  module Cucumber
5
6
  module Filters
6
-
7
- # Batches up all test cases, randomizes them, and then sends them on
7
+ # Batches up all test cases, randomizes them, and then sends them on
8
8
  class Randomizer
9
- def initialize(seed, receiver=nil)
9
+ def initialize(seed, receiver = nil)
10
10
  @receiver = receiver
11
11
  @test_cases = []
12
12
  @seed = seed
@@ -33,14 +33,13 @@ module Cucumber
33
33
 
34
34
  def shuffled_test_cases
35
35
  digester = Digest::SHA2.new(256)
36
- @test_cases.map.with_index.
37
- sort_by { |_, index| digester.digest((@seed + index).to_s) }.
38
- map { |test_case, _| test_case }
36
+ @test_cases.map.with_index
37
+ .sort_by { |_, index| digester.digest((@seed + index).to_s) }
38
+ .map { |test_case, _| test_case }
39
39
  end
40
40
 
41
41
  attr_reader :seed
42
42
  private :seed
43
43
  end
44
-
45
44
  end
46
45
  end