Permalink
Browse files

instantiate legacy formatters after we've tinkered with the class to …

…restore attributes etc
  • Loading branch information...
1 parent b362acc commit 7e6f2734b45c03c65340430ce74db5ce832e5722 @JonRowe JonRowe committed Feb 7, 2014
Showing with 9 additions and 7 deletions.
  1. +5 −3 lib/rspec/core/formatters.rb
  2. +4 −4 lib/rspec/core/formatters/legacy_formatter.rb
@@ -98,13 +98,15 @@ def setup_default(output_stream, deprecation_stream)
def add(formatter_to_use, *paths)
@formatter_added = true
formatter_class = find_formatter(formatter_to_use)
- formatter = formatter_class.new(*paths.map {|p| String === p ? file_at(p) : p})
+
+ args = paths.map { |p| String === p ? file_at(p) : p }
if !Loader.formatters[formatter_class].nil?
+ formatter = formatter_class.new(*args)
@reporter.register_listener formatter, *notifications_for(formatter_class)
else
- RSpec.warn_deprecation "The #{formatter.class} formatter uses the deprecated formatter interface.\n Formatter added at: #{::RSpec::CallerFilter.first_non_rspec_line}"
- formatter = LegacyFormatter.new(formatter)
+ RSpec.warn_deprecation "The #{formatter_class} formatter uses the deprecated formatter interface.\n Formatter added at: #{::RSpec::CallerFilter.first_non_rspec_line}"
+ formatter = LegacyFormatter.new(formatter_class, *args)
@reporter.register_listener formatter, *formatter.notifications
end
@@ -91,13 +91,13 @@ def stop
# @api public
#
# @param formatter
- def initialize(oldstyle_formatter)
- @formatter = oldstyle_formatter
- if @formatter.class.ancestors.include?(BaseFormatter)
- @formatter.class.class_eval do
+ def initialize(formatter_class, *args)
+ if formatter_class.ancestors.include?(BaseFormatter)
+ formatter_class.class_eval do
include LegacyInterface
end
end
+ @formatter = formatter_class.new(*args)
end
# @api public

0 comments on commit 7e6f273

Please sign in to comment.