Skip to content

Commit

Permalink
Remove the legacy_api.
Browse files Browse the repository at this point in the history
  • Loading branch information
brasmusson committed Jul 7, 2018
1 parent 268a038 commit d783165
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 3,772 deletions.
2 changes: 0 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ AllCops:
Exclude:
- 'tmp/**/*'
- 'vendor/**/*'
- 'lib/cucumber/formatter/legacy_api/*'
- 'spec/cucumber/formatter/legacy_api/*'

# Reviewed: please see PR-1022 for details on why this cop is disabled:
# https://github.com/cucumber/cucumber-ruby/pull/1022
Expand Down
2 changes: 1 addition & 1 deletion features/docs/api/listen_for_events.feature
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Feature: Listen for events
"""
Feature:
Scenario:
Given passing
Given this step passes
"""
And the standard step definitions
And a file named "features/support/my_listener.rb" with:
Expand Down
32 changes: 0 additions & 32 deletions features/docs/extending_cucumber/custom_formatter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -60,35 +60,3 @@ Feature: Custom Formatter
"""
{"foo"=>"bar", "one"=>"two"}
"""

Scenario: Use the legacy API
This is deprecated and should no longer be used.

Given a file named "features/support/custom_legacy_formatter.rb" with:
"""
module MyCustom
class LegacyFormatter
def initialize(runtime, io, options)
@io = io
end
def before_feature(feature)
@io.puts feature.short_name.upcase
end
def scenario_name(keyword, name, file_colon_line, source_indent)
@io.puts " #{name.upcase}"
end
end
end
"""
When I run `cucumber features/f.feature --format MyCustom::LegacyFormatter`
Then it should pass with exactly:
"""
WARNING: The formatter MyCustom::LegacyFormatter is using the deprecated formatter API which will be removed in v4.0 of Cucumber.
I'LL USE MY OWN
JUST PRINT ME
"""

2 changes: 1 addition & 1 deletion features/docs/formatters/api_methods.feature
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Feature: Formatter API methods
module Formatter
class Test
include Io
def initialize(runtime, path_or_io, options)
def initialize(config)
ensure_file("my/special/output.file", "custom formatter")
end
end
Expand Down
3 changes: 1 addition & 2 deletions lib/cucumber/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ def formatter_factories
factory = formatter_class(format)
yield factory,
formatter_options,
path_or_io,
Cli::Options.new(STDOUT, STDERR, @options)
path_or_io
rescue Exception => e
raise e, "#{e.message}\nError creating formatter: #{format}", e.backtrace
end
Expand Down
7 changes: 1 addition & 6 deletions lib/cucumber/filters/prepare_world.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@ def test_case
end
around_hooks = [init_scenario] + @original_test_case.around_hooks

empty_hook = proc {} # no op - legacy format adapter expects a before hooks
empty_hook_location = Cucumber::Core::Ast::Location.from_source_location(*empty_hook.source_location)
default_hook = Cucumber::Hooks.before_hook(@original_test_case.source, empty_hook_location, &empty_hook)
steps = [default_hook] + @original_test_case.test_steps

@original_test_case.with_around_hooks(around_hooks).with_steps(steps)
@original_test_case.with_around_hooks(around_hooks).with_steps(@original_test_case.test_steps)
end

private
Expand Down
Loading

0 comments on commit d783165

Please sign in to comment.