cucumber 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +10 -0
  3. data/Gemfile +3 -1
  4. data/History.md +18 -2
  5. data/README.md +5 -1
  6. data/cucumber.gemspec +3 -4
  7. data/cucumber.yml +2 -2
  8. data/features/docs/api/run_cli_main_with_existing_runtime.feature +4 -7
  9. data/features/docs/defining_steps/skip_scenario.feature +6 -2
  10. data/features/docs/formatters/api_methods.feature +36 -0
  11. data/features/docs/profiles.feature +2 -2
  12. data/features/lib/step_definitions/profile_steps.rb +1 -1
  13. data/lib/cucumber.rb +11 -4
  14. data/lib/cucumber/cli/configuration.rb +2 -2
  15. data/lib/cucumber/cli/options.rb +2 -2
  16. data/lib/cucumber/configuration.rb +25 -3
  17. data/lib/cucumber/deprecate.rb +29 -0
  18. data/lib/cucumber/filters/activate_steps.rb +39 -5
  19. data/lib/cucumber/formatter/console.rb +4 -4
  20. data/lib/cucumber/formatter/io.rb +1 -1
  21. data/lib/cucumber/formatter/legacy_api/adapter.rb +30 -30
  22. data/lib/cucumber/formatter/legacy_api/runtime_facade.rb +4 -9
  23. data/lib/cucumber/platform.rb +2 -7
  24. data/lib/cucumber/rb_support/rb_language.rb +72 -26
  25. data/lib/cucumber/rb_support/rb_step_definition.rb +2 -2
  26. data/lib/cucumber/rb_support/rb_world.rb +6 -1
  27. data/lib/cucumber/rb_support/snippet.rb +21 -0
  28. data/lib/cucumber/running_test_case.rb +5 -1
  29. data/lib/cucumber/runtime.rb +11 -15
  30. data/lib/cucumber/runtime/support_code.rb +20 -128
  31. data/lib/cucumber/step_argument.rb +25 -0
  32. data/lib/cucumber/step_match.rb +6 -12
  33. data/lib/cucumber/step_match_search.rb +67 -0
  34. data/lib/cucumber/version +1 -0
  35. data/spec/cucumber/configuration_spec.rb +3 -2
  36. data/spec/cucumber/filters/activate_steps_spec.rb +95 -3
  37. data/spec/cucumber/formatter/html_spec.rb +1 -1
  38. data/spec/cucumber/formatter/legacy_api/adapter_spec.rb +55 -28
  39. data/spec/cucumber/formatter/pretty_spec.rb +2 -2
  40. data/spec/cucumber/formatter/spec_helper.rb +22 -12
  41. data/spec/cucumber/rb_support/rb_language_spec.rb +9 -45
  42. data/spec/cucumber/rb_support/rb_step_definition_spec.rb +2 -2
  43. data/spec/cucumber/rb_support/rb_world_spec.rb +47 -0
  44. data/spec/cucumber/runtime/for_programming_languages_spec.rb +1 -1
  45. data/spec/cucumber/runtime/support_code_spec.rb +4 -111
  46. data/spec/cucumber/step_argument_spec.rb +18 -0
  47. data/spec/cucumber/step_match_search_spec.rb +122 -0
  48. data/spec/cucumber/step_match_spec.rb +8 -2
  49. data/spec/cucumber/world/pending_spec.rb +2 -1
  50. data/spec/cucumber_spec.rb +39 -0
  51. metadata +45 -50
  52. data/features/docs/wire_protocol/erb_configuration.feature +0 -56
  53. data/features/docs/wire_protocol/handle_unexpected_response.feature +0 -30
  54. data/features/docs/wire_protocol/invoke_message.feature +0 -216
  55. data/features/docs/wire_protocol/readme.md +0 -26
  56. data/features/docs/wire_protocol/snippets_message.feature +0 -51
  57. data/features/docs/wire_protocol/step_matches_message.feature +0 -81
  58. data/features/docs/wire_protocol/table_diffing.feature +0 -126
  59. data/features/docs/wire_protocol/tags.feature +0 -87
  60. data/features/docs/wire_protocol/timeouts.feature +0 -64
  61. data/lib/cucumber/events/bus.rb +0 -86
  62. data/lib/cucumber/gherkin/formatter/argument.rb +0 -17
  63. data/lib/cucumber/gherkin/formatter/hashable.rb +0 -27
  64. data/lib/cucumber/language_support.rb +0 -30
  65. data/lib/cucumber/language_support/language_methods.rb +0 -72
  66. data/lib/cucumber/rb_support/regexp_argument_matcher.rb +0 -21
  67. data/lib/cucumber/wire_support/configuration.rb +0 -38
  68. data/lib/cucumber/wire_support/connection.rb +0 -61
  69. data/lib/cucumber/wire_support/request_handler.rb +0 -32
  70. data/lib/cucumber/wire_support/wire_exception.rb +0 -32
  71. data/lib/cucumber/wire_support/wire_language.rb +0 -68
  72. data/lib/cucumber/wire_support/wire_packet.rb +0 -34
  73. data/lib/cucumber/wire_support/wire_protocol.rb +0 -43
  74. data/lib/cucumber/wire_support/wire_protocol/requests.rb +0 -133
  75. data/lib/cucumber/wire_support/wire_step_definition.rb +0 -21
  76. data/spec/cucumber/events/bus_spec.rb +0 -94
  77. data/spec/cucumber/rb_support/regexp_argument_matcher_spec.rb +0 -22
  78. data/spec/cucumber/wire_support/configuration_spec.rb +0 -64
  79. data/spec/cucumber/wire_support/connection_spec.rb +0 -64
  80. data/spec/cucumber/wire_support/wire_exception_spec.rb +0 -50
  81. data/spec/cucumber/wire_support/wire_language_spec.rb +0 -46
  82. data/spec/cucumber/wire_support/wire_packet_spec.rb +0 -44
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4396d10625822b4e94db4edbb67438e3e4394dae
4
- data.tar.gz: 45960cc6f1cf3e3189dfd4f4ab5ac27c8ff8e4a3
3
+ metadata.gz: e99af93e987e5bd5b6424cda154b6f9ef1d4a834
4
+ data.tar.gz: db6cd2d1d62695ef7dd72a6b9505e921bc8b7e84
5
5
  SHA512:
6
- metadata.gz: ac22570755b443d4f1cdb9a546d46f92283722d1cc799bb59274dd9cc476b0c609a471247ea7d1c7a2d8598d6d0d5e41c2efef49ce10b150e4337109d4cc998f
7
- data.tar.gz: 125c07dddc5d0039333c677860a93820103871c9db3c3bba57d23496d4c07879208178c3a929d84c74bff15a14a4618cf7c12162c242d83e7b2533bc0261e357
6
+ metadata.gz: 965176d82959413e7551f10890c255ab09dafbb5a43ceb3072a81c89f6eb2775661506b6a8a1d188e596978c4d6ad654dd0859a5aafe058fcdfa707f5bfe6799
7
+ data.tar.gz: 9a5627119ee9557b23a6cfd5107694af06f5a7f30fb566ce47076519fb0c664b9debba4f3cb609fef2f758c2fc177c16715b8820ae66aef78b64b3da2d436295
@@ -10,3 +10,13 @@ branches:
10
10
  only:
11
11
  - master
12
12
  - v1.3.x-bugfix
13
+
14
+ before_install:
15
+ - gem update bundler
16
+
17
+ notifications:
18
+ email:
19
+ - cukes-devs@googlegroups.com
20
+ webhooks:
21
+ urls: # gitter
22
+ - https://webhooks.gitter.im/e/dc010332f9d40fcc21c4
data/Gemfile CHANGED
@@ -3,9 +3,11 @@ source "https://rubygems.org"
3
3
  gemspec
4
4
  unless ENV['CUCUMBER_USE_RELEASED_CORE']
5
5
  core_path = File.expand_path("../../cucumber-ruby-core", __FILE__)
6
+ wire_path = File.expand_path("../../cucumber-ruby-wire", __FILE__)
6
7
  if File.exist?(core_path) && !ENV['CUCUMBER_USE_GIT_CORE']
7
8
  gem 'cucumber-core', :path => core_path
9
+ gem 'cucumber-wire', :path => wire_path
8
10
  else
9
- gem 'cucumber-core', :git => "git://github.com/cucumber/cucumber-ruby-core.git", branch: "integrate-gherkin3-parser"
11
+ gem 'cucumber-core', :git => "git://github.com/cucumber/cucumber-ruby-core.git"
10
12
  end
11
13
  end
data/History.md CHANGED
@@ -1,4 +1,20 @@
1
- ## [In Git](https://github.com/cucumber/cucumber-ruby/compare/v2.0.2...master)
1
+ ## [In Git](https://github.com/cucumber/cucumber-ruby/compare/v2.1...master)
2
+
3
+ ### New Features
4
+
5
+ ### Bugfixes
6
+
7
+ * Let the formatters output the value of printed variables at time of the call to `#puts` ([#918](https://github.com/cucumber/cucumber-ruby/pull/918) [#915](https://github.com/cucumber/cucumber-ruby/issues/915) @enkessler @brasmusson)
8
+ * Fix Configuration.with_options merge direction ([#922](https://github.com/cucumber/cucumber-ruby/pull/922) @limhoff-r7)
9
+ * Consistent line breaks / truncation in backtraces ([#941](https://github.com/cucumber/cucumber-ruby/pull/941) @tooky)
10
+ * Fix extra arg passed to ensure_io ([#939](https://github.com/cucumber/cucumber-ruby/pull/939A @benshan)
11
+
12
+ ### Refactoring
13
+
14
+ * Remove wire protocol to plugin ([#878](https://github.com/cucumber/cucumber-ruby/pull/878) @mattwynne @tooky)
15
+ * Remove event bus to separate gem ([#933](https://github.com/cucumber/cucumber-ruby/pull/933) @dg-ratiodata)
16
+
17
+ ## [v2.1](https://github.com/cucumber/cucumber-ruby/compare/v2.0.2...v2.1)
2
18
 
3
19
  ### New Features
4
20
 
@@ -16,7 +32,7 @@
16
32
  * Pass DocString as String ([891](https://github.com/cucumber/cucumber-ruby/pull/891) @aslakhellesoy)
17
33
  * Remove core_ext/proc.rb and use Proc#source_location instead ([888](https://github.com/cucumber/cucumber-ruby/pull/888) @brasmusson)
18
34
  * Move behaviour from `Cucumber::Cli::Configuration` to `Cucumber::Configuration` (@tooky, @mattwynne)
19
- * Integrate Gherkin3 parser ([884](https://github.com/cucumber/cucumber-ruby/pull/884) (@brassmusson)
35
+ * Integrate Gherkin3 parser ([884](https://github.com/cucumber/cucumber-ruby/pull/884) (@brasmusson)
20
36
 
21
37
  ## [v2.0.2](https://github.com/cucumber/cucumber-ruby/compare/v2.0.1...v2.0.2)
22
38
 
data/README.md CHANGED
@@ -1,4 +1,8 @@
1
- [![Join the chat at https://gitter.im/cucumber/cucumber-ruby](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/cucumber/cucumber-ruby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://secure.travis-ci.org/cucumber/cucumber-ruby.png)](http://travis-ci.org/cucumber/cucumber-ruby) [![Code Climate](https://codeclimate.com/github/cucumber/cucumber-ruby.png)](https://codeclimate.com/github/cucumber/cucumber-ruby) [![Coverage Status](https://coveralls.io/repos/cucumber/cucumber-ruby/badge.svg?branch=master)](https://coveralls.io/r/cucumber/cucumber-ruby?branch=master) [![Dependency Status](https://gemnasium.com/cucumber/cucumber-ruby.png)](https://gemnasium.com/cucumber/cucumber-ruby)
1
+ [![Join the chat at https://gitter.im/cucumber/cucumber-ruby](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/cucumber/cucumber-ruby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
2
+ [![Build Status](https://secure.travis-ci.org/cucumber/cucumber-ruby.svg)](http://travis-ci.org/cucumber/cucumber-ruby)
3
+ [![Code Climate](https://codeclimate.com/github/cucumber/cucumber-ruby.svg)](https://codeclimate.com/github/cucumber/cucumber-ruby)
4
+ [![Coverage Status](https://coveralls.io/repos/cucumber/cucumber-ruby/badge.svg?branch=master)](https://coveralls.io/r/cucumber/cucumber-ruby?branch=master)
5
+ [![Dependency Status](https://gemnasium.com/cucumber/cucumber-ruby.svg)](https://gemnasium.com/cucumber/cucumber-ruby)
2
6
 
3
7
  # Cucumber
4
8
 
@@ -1,10 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
3
- require "cucumber/platform"
4
-
5
2
  Gem::Specification.new do |s|
6
3
  s.name = 'cucumber'
7
- s.version = Cucumber::VERSION
4
+ s.version = File.read(File.expand_path("../lib/cucumber/version", __FILE__))
8
5
  s.authors = ["Aslak Hellesøy", "Matt Wynne", "Steve Tooke"]
9
6
  s.description = 'Behaviour Driven Development with elegance and joy'
10
7
  s.summary = "cucumber-#{s.version}"
@@ -20,6 +17,8 @@ Gem::Specification.new do |s|
20
17
  s.add_dependency 'gherkin3', '~> 3.1.0'
21
18
  s.add_dependency 'multi_json', '>= 1.7.5', '< 2.0'
22
19
  s.add_dependency 'multi_test', '>= 0.1.2'
20
+ s.add_dependency 'cucumber-wire', '~> 0.0.1'
21
+ s.add_dependency 'event-bus', '~> 0.1.0'
23
22
 
24
23
  s.add_development_dependency 'aruba', '~> 0.6.1'
25
24
  s.add_development_dependency 'json', '~> 1.7'
@@ -2,7 +2,7 @@
2
2
  cucumber_pro_opts = ENV['ENABLE_CUCUMBER_PRO'] ? "--format Cucumber::Pro --out /dev/null" : ""
3
3
  rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
4
4
  rerun_opts = rerun.to_s.strip.empty? ? "--format progress features" : "--format pretty #{rerun}"
5
- std_opts = "--format progress features --tags ~@wip --tag ~@wip-new-core -r features --strict #{cucumber_pro_opts}"
5
+ std_opts = "--format progress features --tags ~@wip --tags ~@wip-new-core -r features --strict #{cucumber_pro_opts}"
6
6
  std_opts << " --tags ~@wip-jruby" if defined?(JRUBY_VERSION)
7
7
 
8
8
  wip_opts = "--color -r features --tags @wip,@wip-new-core"
@@ -17,4 +17,4 @@ ruby_2_0: <%= std_opts %> --tags ~@jruby
17
17
  ruby_2_1: <%= std_opts %> --tags ~@jruby
18
18
  wip: --wip <%= wip_opts %> features <%= cucumber_pro_opts %>
19
19
  none: --format pretty --format Cucumber::Pro --out /dev/null
20
- rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip --tag ~@wip-new-core <%= cucumber_pro_opts %>
20
+ rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tag ~@wip-new-core <%= cucumber_pro_opts %>
@@ -1,26 +1,23 @@
1
1
  @spawn
2
2
  Feature: Run Cli::Main with existing Runtime
3
3
 
4
- This is the API that Spork uses. It creates an existing runtime then
5
- calls load_programming_language('rb') on it to load the RbDsl.
6
- When the process forks, Spork them passes the runtime to Cli::Main to
4
+ This is the API that Spork uses. It creates an existing runtime.
5
+ When the process forks, Spork them passes the runtime to Cli::Main to
7
6
  run it.
8
7
 
9
8
  Scenario: Run a single feature
10
9
  Given the standard step definitions
11
10
  Given a file named "features/success.feature" with:
12
11
  """
13
- Feature:
14
- Scenario:
12
+ Feature:
13
+ Scenario:
15
14
  Given this step passes
16
15
  """
17
16
  When I run the following Ruby code:
18
17
  """
19
18
  require 'cucumber'
20
19
  runtime = Cucumber::Runtime.new
21
- runtime.load_programming_language('rb')
22
20
  Cucumber::Cli::Main.new([]).execute!(runtime)
23
-
24
21
  """
25
22
  Then it should pass
26
23
  And the output should contain:
@@ -29,7 +29,8 @@ Feature: Skip Scenario
29
29
 
30
30
  """
31
31
 
32
- Scenario: Use legacy API from a hook
32
+ @spawn
33
+ Scenario: Use (deprecated) legacy API
33
34
  Given a file named "features/test.feature" with:
34
35
  """
35
36
  Feature: test
@@ -57,4 +58,7 @@ Feature: Skip Scenario
57
58
  2 steps (2 skipped)
58
59
 
59
60
  """
60
-
61
+ And the stderr should contain:
62
+ """
63
+ WARNING: skip_invoke! is deprecated
64
+ """
@@ -0,0 +1,36 @@
1
+ Feature: Formatter API methods
2
+
3
+ Some utility methods are provided to make it easier to write your own formatters.
4
+
5
+ Here are some examples.
6
+
7
+ Scenario: A formatter that uses `Cucumber::Formatter::Io#ensure_file`
8
+
9
+ The ensure_file method is a little helper function that some formatters use,
10
+ normally when given a CLI argument with `--out` to check that the file passed
11
+ by the user actually exists.
12
+
13
+ The second argument is the name of the formatter, used to print a useful
14
+ error message if the file can't be created for some reason.
15
+
16
+ Given a file named "features/f.feature" with:
17
+ """
18
+ Feature: Test
19
+ Scenario: Test
20
+ """
21
+ And a file named "features/support/custom_formatter.rb" with:
22
+ """
23
+ require 'cucumber/formatter/io'
24
+ module Cucumber
25
+ module Formatter
26
+ class Test
27
+ include Io
28
+ def initialize(runtime, path_or_io, options)
29
+ ensure_file("my/special/output.file", "custom formatter")
30
+ end
31
+ end
32
+ end
33
+ end
34
+ """
35
+ When I run `cucumber features/f.feature --format Cucumber::Formatter::Test`
36
+ Then it should pass
@@ -84,10 +84,10 @@ Feature: Profiles
84
84
  Scenario: Overriding the profile's features to run
85
85
  Given a file named "features/another.feature" with:
86
86
  """
87
- Feature: Just this one should be ran
87
+ Feature: Just this one should be run
88
88
  """
89
89
  When I run `cucumber -p default features/another.feature`
90
- Then exactly these features should be ran: features/another.feature
90
+ Then exactly these features should be run: features/another.feature
91
91
 
92
92
  Scenario: Overriding the profile's formatter
93
93
  You will most likely want to define a formatter in your default formatter.
@@ -10,6 +10,6 @@ Then /^exactly these files should be loaded:\s*(.*)$/ do |files|
10
10
  expect(all_stdout.scan(/^ \* (.*\.rb)$/).flatten).to eq files.split(/,\s+/)
11
11
  end
12
12
 
13
- Then /^exactly these features should be ran:\s*(.*)$/ do |files|
13
+ Then /^exactly these features should be run:\s*(.*)$/ do |files|
14
14
  expect(all_stdout.scan(/^ \* (.*\.feature)$/).flatten).to eq files.split(/,\s+/)
15
15
  end
@@ -21,10 +21,17 @@ module Cucumber
21
21
  @log = logger
22
22
  end
23
23
 
24
- def deprecate(class_name, method, message)
25
- return self # deprecation warnings will come in v2.1
26
- called_by = caller[1]
27
- warn("Deprecated: #{class_name}##{method} #{message}. Caller: #{called_by}")
24
+ if Cucumber::RUBY_1_9
25
+ # Backported from Ruby 2.0 to 1.9
26
+ def Hash(other)
27
+ return {} if other.nil? || other == []
28
+ raise TypeError, "can't convert #{other.class} into Hash" unless other.respond_to?(:to_hash)
29
+ other.to_hash
30
+ end
31
+ else
32
+ def Hash(other)
33
+ Kernel::Hash(other)
34
+ end
28
35
  end
29
36
  end
30
37
  end
@@ -114,7 +114,7 @@ module Cucumber
114
114
  end
115
115
 
116
116
  def to_hash
117
- Hash.try_convert(@options).merge(out_stream: @out_stream, error_stream: @error_stream)
117
+ Cucumber::Hash(@options).merge(out_stream: @out_stream, error_stream: @error_stream)
118
118
  end
119
119
 
120
120
  private
@@ -139,4 +139,4 @@ module Cucumber
139
139
  end
140
140
  end
141
141
  end
142
- end
142
+ end
@@ -294,7 +294,7 @@ TEXT
294
294
  end
295
295
 
296
296
  def to_hash
297
- Hash.try_convert(@options)
297
+ Cucumber::Hash(@options)
298
298
  end
299
299
 
300
300
  protected
@@ -456,4 +456,4 @@ TEXT
456
456
  end
457
457
 
458
458
  end
459
- end
459
+ end
@@ -3,6 +3,9 @@ require 'cucumber/cli/rerun_file'
3
3
  require 'cucumber/events'
4
4
  require 'forwardable'
5
5
  require 'cucumber/core/gherkin/tag_expression'
6
+ require 'cucumber'
7
+ require 'event/bus'
8
+ require 'event/name_resolver'
6
9
 
7
10
  module Cucumber
8
11
  # The base class for configuring settings for a Cucumber run.
@@ -28,11 +31,11 @@ module Cucumber
28
31
  def_instance_delegator :event_bus, :notify
29
32
 
30
33
  def initialize(user_options = {})
31
- @options = default_options.merge(Hash.try_convert(user_options))
34
+ @options = default_options.merge(Cucumber::Hash(user_options))
32
35
  end
33
36
 
34
37
  def with_options(new_options)
35
- self.class.new(new_options.merge(@options))
38
+ self.class.new(@options.merge(new_options))
36
39
  end
37
40
 
38
41
  # TODO: Actually Deprecate???
@@ -193,6 +196,25 @@ module Cucumber
193
196
  @options
194
197
  end
195
198
 
199
+ # An array of procs that can generate snippets for undefined steps. These procs may be called if a
200
+ # formatter wants to display snippets to the user.
201
+ #
202
+ # Each proc should take the following arguments:
203
+ #
204
+ # - keyword
205
+ # - step text
206
+ # - multiline argument
207
+ # - snippet type
208
+ #
209
+ def snippet_generators
210
+ @options[:snippet_generators] ||= []
211
+ end
212
+
213
+ def register_snippet_generator(generator)
214
+ snippet_generators << generator
215
+ self
216
+ end
217
+
196
218
  private
197
219
 
198
220
  def default_options
@@ -212,7 +234,7 @@ module Cucumber
212
234
  :snippets => true,
213
235
  :source => true,
214
236
  :duration => true,
215
- :event_bus => Events::Bus.new(Cucumber::Events)
237
+ :event_bus => Event::Bus.new(Event::NameResolver.new(Cucumber::Events))
216
238
  }
217
239
  end
218
240
 
@@ -0,0 +1,29 @@
1
+ require 'cucumber/platform'
2
+ require 'cucumber/gherkin/formatter/ansi_escapes'
3
+
4
+ module Cucumber
5
+ module Deprecate
6
+ module ForUsers
7
+ AnsiEscapes = Cucumber::Gherkin::Formatter::AnsiEscapes
8
+
9
+ def self.call(message, method, remove_after_version)
10
+ STDERR.puts AnsiEscapes.failed + "WARNING: #{method} is deprecated and will be removed after version #{remove_after_version}. #{message}" + AnsiEscapes.reset
11
+ end
12
+ end
13
+
14
+ module ForDevelopers
15
+ def self.call(message, method, remove_after_version)
16
+ if Cucumber::VERSION > remove_after_version
17
+ raise "This method is due for removal after version #{remove_after_version}"
18
+ end
19
+ end
20
+ end
21
+
22
+ Strategy = $0.match(/rspec$/) ? ForDevelopers : ForUsers
23
+ end
24
+
25
+ def self.deprecate(*args)
26
+ Deprecate::Strategy.call(*args)
27
+ end
28
+
29
+ end
@@ -1,17 +1,21 @@
1
1
  require 'cucumber/core/filter'
2
+ require 'cucumber/step_match'
3
+ require 'cucumber/events'
4
+ require 'cucumber/errors'
2
5
 
3
6
  module Cucumber
4
7
  module Filters
5
- class ActivateSteps < Core::Filter.new(:step_definitions)
8
+ class ActivateSteps < Core::Filter.new(:step_match_search, :configuration)
6
9
 
7
10
  def test_case(test_case)
8
- CaseFilter.new(test_case, step_definitions).test_case.describe_to receiver
11
+ CaseFilter.new(test_case, step_match_search, configuration).test_case.describe_to receiver
9
12
  end
10
13
 
11
14
  class CaseFilter
12
- def initialize(test_case, step_definitions)
15
+ def initialize(test_case, step_match_search, configuration)
13
16
  @original_test_case = test_case
14
- @step_definitions = step_definitions
17
+ @step_match_search = step_match_search
18
+ @configuration = configuration
15
19
  end
16
20
 
17
21
  def test_case
@@ -25,7 +29,37 @@ module Cucumber
25
29
  end
26
30
 
27
31
  def attempt_to_activate(test_step)
28
- @step_definitions.find_match(test_step).activate(test_step)
32
+ find_match(test_step).activate(test_step)
33
+ end
34
+
35
+ def find_match(test_step)
36
+ FindMatch.new(@step_match_search, @configuration, test_step).result
37
+ end
38
+
39
+ class FindMatch
40
+ def initialize(step_match_search, configuration, test_step)
41
+ @step_match_search, @configuration, @test_step = step_match_search, configuration, test_step
42
+ end
43
+
44
+ def result
45
+ return NoStepMatch.new(test_step.source.last, test_step.name) unless matches.any?
46
+ configuration.notify Events::StepMatch.new(test_step, match)
47
+ return SkippingStepMatch.new if configuration.dry_run?
48
+ match
49
+ end
50
+
51
+ private
52
+
53
+ attr_reader :step_match_search, :configuration, :test_step
54
+ private :step_match_search, :configuration, :test_step
55
+
56
+ def match
57
+ matches.first
58
+ end
59
+
60
+ def matches
61
+ step_match_search.call(test_step.name)
62
+ end
29
63
  end
30
64
  end
31
65
  end
@@ -69,7 +69,8 @@ module Cucumber
69
69
  if status == :failed
70
70
  print_exception(element.exception, status, 0)
71
71
  else
72
- @io.puts(format_string(element.backtrace_line, status))
72
+ message = linebreaks(element.backtrace_line, ENV['CUCUMBER_TRUNCATE_OUTPUT'].to_i)
73
+ @io.puts(format_string(message, status))
73
74
  end
74
75
  @io.puts
75
76
  @io.flush
@@ -123,9 +124,7 @@ module Cucumber
123
124
 
124
125
  def print_exception(e, status, indent)
125
126
  message = "#{e.message} (#{e.class})".force_encoding("UTF-8")
126
- if ENV['CUCUMBER_TRUNCATE_OUTPUT']
127
- message = linebreaks(message, ENV['CUCUMBER_TRUNCATE_OUTPUT'].to_i)
128
- end
127
+ message = linebreaks(message, ENV['CUCUMBER_TRUNCATE_OUTPUT'].to_i)
129
128
 
130
129
  string = "#{message}\n#{e.backtrace.join("\n")}".indent(indent)
131
130
  @io.puts(format_string(string, status))
@@ -133,6 +132,7 @@ module Cucumber
133
132
 
134
133
  # http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/10655
135
134
  def linebreaks(s, max)
135
+ return s unless max && max > 0
136
136
  s.gsub(/.{1,#{max}}(?:\s|\Z)/){($& + 5.chr).gsub(/\n\005/,"\n").gsub(/\005/,"\n")}.rstrip
137
137
  end
138
138