Skip to content

Commit

Permalink
Revert "Remove special case output to STDOUT". The examples weren't f…
Browse files Browse the repository at this point in the history
…ailing before the implementation change and the patch introduced a new bug.

This reverts commit 3457a3a.
  • Loading branch information
dchelimsky committed May 29, 2008
1 parent a021e7b commit cb5aba3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 22 deletions.
9 changes: 7 additions & 2 deletions lib/spec/runner/formatter/base_text_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ def initialize(options, where)
super
if where.is_a?(String)
@output = File.open(where, 'w')
elsif where == STDOUT
@output = Kernel
def @output.flush
STDOUT.flush
end
else
@output = where
end
Expand Down Expand Up @@ -76,7 +81,7 @@ def dump_pending
end

def close
if IO === @output && @output != STDOUT
if IO === @output
@output.close
end
end
Expand Down Expand Up @@ -107,7 +112,7 @@ def colour(text, colour_code)

def output_to_tty?
begin
@output.tty?
@output == Kernel || @output.tty?
rescue NoMethodError
false
end
Expand Down
20 changes: 0 additions & 20 deletions spec/spec/runner/formatter/story/plain_text_formatter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -320,26 +320,6 @@ module Story
@out.string.should include('When I say hey (SKIPPED)')
end

it "should use colour codes on a tty" do
@out.stub!(:tty?).and_return(true)
@options.stub!(:colour).and_return(true)

@formatter.scenario_started('','')
@formatter.step_succeeded(:given, 'a context')

@out.string.should =~ /\e/m
end

it "should not use colour codes on a non-tty" do
@out.stub!(:tty?).and_return(false)
@options.stub!(:colour).and_return(true)

@formatter.scenario_started('','')
@formatter.step_succeeded(:given, 'a context')

@out.string.should_not =~ /\e/m
end

it "should print steps which succeeded in green" do
@out.stub!(:tty?).and_return(true)
@options.stub!(:colour).and_return(true)
Expand Down

0 comments on commit cb5aba3

Please sign in to comment.