Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initialize formatters with output

  • Loading branch information...
commit e2eb18eafbc368c428164a3e93c4e8d2d36b87aa 1 parent 9aa73b5
@dchelimsky dchelimsky authored
View
2  lib/rspec/core/configuration.rb
@@ -155,7 +155,7 @@ def formatter=(formatter_to_use)
end
def formatter
- @formatter ||= formatter_class.new
+ @formatter ||= formatter_class.new(output)
end
def files_or_directories_to_run=(*files)
View
9 lib/rspec/core/formatters/base_formatter.rb
@@ -5,18 +5,15 @@ module Formatters
class BaseFormatter
include Helpers
attr_accessor :example_group
- attr_reader :example_count, :duration, :examples
+ attr_reader :example_count, :duration, :examples, :output
- def initialize
+ def initialize(output)
+ @output = output
@example_count = 0
@examples = []
@example_group = nil
end
- def output
- configuration.output
- end
-
def pending_examples
@pending_examples ||= ::RSpec.world.find(examples, :execution_result => { :status => 'pending' })
end
View
4 lib/rspec/core/formatters/documentation_formatter.rb
@@ -6,8 +6,8 @@ module Formatters
class DocumentationFormatter < BaseTextFormatter
- def initialize
- super
+ def initialize(output)
+ super(output)
@previous_nested_example_groups = []
end
View
3  spec/rspec/core/formatters/base_formatter_spec.rb
@@ -2,7 +2,8 @@
describe RSpec::Core::Formatters::BaseFormatter do
- let(:formatter) { RSpec::Core::Formatters::BaseFormatter.new }
+ let(:output) { StringIO.new }
+ let(:formatter) { RSpec::Core::Formatters::BaseFormatter.new(output) }
it "has start as an interface with one argument" do
formatter.should have_interface_for(:start).with(1).argument
View
3  spec/rspec/core/formatters/base_text_formatter_spec.rb
@@ -8,10 +8,9 @@ module RSpec::Core::Formatters
output = StringIO.new
group = RSpec::Core::ExampleGroup.describe
example = group.example { "this".should eq("that") }
- formatter = RSpec::Core::Formatters::BaseTextFormatter.new
+ formatter = RSpec::Core::Formatters::BaseTextFormatter.new(output)
group.run_all(formatter)
- RSpec.configuration.stub(:output) { output }
RSpec.configuration.stub(:color_enabled?) { false }
formatter.dump_failures
output.string.should =~ /(\s+)expected \"that\"\n\1 got \"this\"/m
View
3  spec/rspec/core/formatters/documentation_formatter_spec.rb
@@ -16,10 +16,9 @@ module RSpec::Core::Formatters
]
output = StringIO.new
- RSpec.configuration.stub(:output) { output }
RSpec.configuration.stub(:color_enabled?) { false }
- formatter = RSpec::Core::Formatters::DocumentationFormatter.new
+ formatter = RSpec::Core::Formatters::DocumentationFormatter.new(output)
examples.each {|e| formatter.example_finished(e) }
View
3  spec/rspec/core/formatters/progress_formatter_spec.rb
@@ -5,10 +5,9 @@
before do
@output = StringIO.new
- @formatter = RSpec::Core::Formatters::ProgressFormatter.new
+ @formatter = RSpec::Core::Formatters::ProgressFormatter.new(@output)
@formatter.start(2)
@formatter.stub!(:color_enabled?).and_return(false)
- @formatter.stub!(:output).and_return(@output)
end
it "should produce line break on start dump" do
Please sign in to comment.
Something went wrong with that request. Please try again.