cucumber 3.1.0 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -3
  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 +54 -52
  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 +8 -7
  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_parsed.rb~ +14 -0
  27. data/lib/cucumber/events/gherkin_source_read.rb +1 -4
  28. data/lib/cucumber/events/step_activated.rb +4 -5
  29. data/lib/cucumber/events/step_definition_registered.rb +4 -8
  30. data/lib/cucumber/events/test_case_finished.rb +0 -4
  31. data/lib/cucumber/events/test_case_started.rb +0 -4
  32. data/lib/cucumber/events/test_run_finished.rb +2 -3
  33. data/lib/cucumber/events/test_run_started.rb +2 -4
  34. data/lib/cucumber/events/test_step_finished.rb +0 -4
  35. data/lib/cucumber/events/test_step_started.rb +1 -5
  36. data/lib/cucumber/file_specs.rb +2 -1
  37. data/lib/cucumber/filters.rb +1 -0
  38. data/lib/cucumber/filters/activate_steps.rb +1 -1
  39. data/lib/cucumber/filters/apply_after_hooks.rb +1 -0
  40. data/lib/cucumber/filters/apply_after_step_hooks.rb +1 -0
  41. data/lib/cucumber/filters/apply_around_hooks.rb +1 -0
  42. data/lib/cucumber/filters/apply_before_hooks.rb +1 -0
  43. data/lib/cucumber/filters/broadcast_test_run_started_event.rb +2 -1
  44. data/lib/cucumber/filters/gated_receiver.rb +1 -2
  45. data/lib/cucumber/filters/prepare_world.rb +2 -5
  46. data/lib/cucumber/filters/quit.rb +2 -3
  47. data/lib/cucumber/filters/randomizer.rb +6 -7
  48. data/lib/cucumber/filters/retry.rb +2 -2
  49. data/lib/cucumber/filters/tag_limits.rb +2 -2
  50. data/lib/cucumber/filters/tag_limits/test_case_index.rb +1 -2
  51. data/lib/cucumber/filters/tag_limits/verifier.rb +1 -2
  52. data/lib/cucumber/formatter/ansicolor.rb +13 -12
  53. data/lib/cucumber/formatter/ast_lookup.rb~ +9 -0
  54. data/lib/cucumber/formatter/backtrace_filter.rb +1 -2
  55. data/lib/cucumber/formatter/console.rb +11 -12
  56. data/lib/cucumber/formatter/console_counts.rb +4 -4
  57. data/lib/cucumber/formatter/console_issues.rb +3 -3
  58. data/lib/cucumber/formatter/duration.rb +1 -0
  59. data/lib/cucumber/formatter/duration_extractor.rb +1 -1
  60. data/lib/cucumber/formatter/fail_fast.rb +9 -6
  61. data/lib/cucumber/formatter/fanout.rb +1 -3
  62. data/lib/cucumber/formatter/hook_query_visitor.rb +1 -0
  63. data/lib/cucumber/formatter/html.rb +27 -31
  64. data/lib/cucumber/formatter/html_builder.rb +2 -1
  65. data/lib/cucumber/formatter/ignore_missing_messages.rb +1 -2
  66. data/lib/cucumber/formatter/interceptor.rb +18 -5
  67. data/lib/cucumber/formatter/io.rb +1 -0
  68. data/lib/cucumber/formatter/json.rb +3 -2
  69. data/lib/cucumber/formatter/json_pretty.rb +1 -0
  70. data/lib/cucumber/formatter/junit.rb +16 -15
  71. data/lib/cucumber/formatter/pretty.rb +4 -3
  72. data/lib/cucumber/formatter/progress.rb +3 -2
  73. data/lib/cucumber/formatter/rerun.rb +1 -0
  74. data/lib/cucumber/formatter/stepdefs.rb +1 -0
  75. data/lib/cucumber/formatter/steps.rb +2 -2
  76. data/lib/cucumber/formatter/summary.rb +1 -1
  77. data/lib/cucumber/formatter/unicode.rb +2 -2
  78. data/lib/cucumber/formatter/usage.rb +22 -19
  79. data/lib/cucumber/gherkin/data_table_parser.rb +1 -0
  80. data/lib/cucumber/gherkin/formatter/ansi_escapes.rb +86 -85
  81. data/lib/cucumber/gherkin/formatter/escaping.rb +13 -12
  82. data/lib/cucumber/gherkin/i18n.rb +1 -0
  83. data/lib/cucumber/gherkin/steps_parser.rb +1 -0
  84. data/lib/cucumber/glue/dsl.rb +1 -0
  85. data/lib/cucumber/glue/hook.rb +1 -0
  86. data/lib/cucumber/glue/invoke_in_world.rb +3 -3
  87. data/lib/cucumber/glue/proto_world.rb +8 -9
  88. data/lib/cucumber/glue/registry_and_more.rb +13 -12
  89. data/lib/cucumber/glue/snippet.rb +1 -5
  90. data/lib/cucumber/glue/step_definition.rb +9 -9
  91. data/lib/cucumber/glue/world_factory.rb +0 -2
  92. data/lib/cucumber/hooks.rb +1 -3
  93. data/lib/cucumber/load_path.rb +1 -0
  94. data/lib/cucumber/multiline_argument.rb +2 -2
  95. data/lib/cucumber/multiline_argument/data_table.rb +10 -10
  96. data/lib/cucumber/multiline_argument/data_table/diff_matrices.rb +7 -10
  97. data/lib/cucumber/multiline_argument/doc_string.rb +1 -0
  98. data/lib/cucumber/platform.rb +2 -1
  99. data/lib/cucumber/project_initializer.rb +1 -1
  100. data/lib/cucumber/rake/task.rb +8 -5
  101. data/lib/cucumber/rspec/disable_option_parser.rb +1 -0
  102. data/lib/cucumber/rspec/doubles.rb +1 -0
  103. data/lib/cucumber/running_test_case.rb +2 -1
  104. data/lib/cucumber/runtime.rb +6 -6
  105. data/lib/cucumber/runtime/after_hooks.rb +1 -0
  106. data/lib/cucumber/runtime/before_hooks.rb +1 -0
  107. data/lib/cucumber/runtime/for_programming_languages.rb +8 -7
  108. data/lib/cucumber/runtime/step_hooks.rb +2 -0
  109. data/lib/cucumber/runtime/support_code.rb +3 -7
  110. data/lib/cucumber/runtime/user_interface.rb +2 -3
  111. data/lib/cucumber/step_argument.rb +1 -0
  112. data/lib/cucumber/step_definition_light.rb +2 -1
  113. data/lib/cucumber/step_definitions.rb +1 -0
  114. data/lib/cucumber/step_match.rb +5 -7
  115. data/lib/cucumber/step_match_search.rb +7 -8
  116. data/lib/cucumber/term/ansicolor.rb +30 -30
  117. data/lib/cucumber/unit.rb +1 -0
  118. data/lib/cucumber/version +1 -1
  119. data/lib/simplecov_setup.rb +1 -0
  120. metadata +64 -118
@@ -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'
@@ -166,8 +167,8 @@ module Cucumber
166
167
  end
167
168
 
168
169
  def support_to_load
169
- support_files = all_files_to_load.select {|f| f =~ %r{/support/} }
170
- env_files = support_files.select {|f| f =~ %r{/support/env\..*} }
170
+ support_files = all_files_to_load.select { |f| f =~ %r{/support/} }
171
+ env_files = support_files.select { |f| f =~ %r{/support/env\..*} }
171
172
  other_files = support_files - env_files
172
173
  @options[:dry_run] ? other_files : env_files + other_files
173
174
  end
@@ -179,14 +180,14 @@ module Cucumber
179
180
  File.directory?(path) ? Dir["#{path}/**/*"] : path
180
181
  end.flatten.uniq
181
182
  remove_excluded_files_from(files)
182
- files.reject! {|f| !File.file?(f)}
183
- files.reject! {|f| File.extname(f) == '.feature' }
184
- files.reject! {|f| f =~ /^http/}
183
+ files.reject! { |f| !File.file?(f) }
184
+ files.reject! { |f| File.extname(f) == '.feature' }
185
+ files.reject! { |f| f =~ /^http/ }
185
186
  files.sort
186
187
  end
187
188
 
188
189
  def step_defs_to_load
189
- all_files_to_load.reject {|f| f =~ %r{/support/} }
190
+ all_files_to_load.reject { |f| f =~ %r{/support/} }
190
191
  end
191
192
 
192
193
  def formatter_factories
@@ -271,7 +272,7 @@ module Cucumber
271
272
  end
272
273
 
273
274
  def remove_excluded_files_from(files)
274
- files.reject! {|path| @options[:excludes].detect {|pattern| path =~ pattern } }
275
+ files.reject! { |path| @options[:excludes].detect { |pattern| path =~ pattern } }
275
276
  end
276
277
 
277
278
  def require_dirs
@@ -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
@@ -0,0 +1,14 @@
1
+ require 'cucumber/core/events'
2
+
3
+ module Cucumber
4
+ module Events
5
+ # Fired after we've read in the contents of a feature file
6
+ class GherkinSourceRead < Core::Event.new(:path, :body)
7
+ # The path to the file
8
+ attr_reader :path
9
+
10
+ # The raw Gherkin source
11
+ attr_reader :body
12
+ end
13
+ end
14
+ end
@@ -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