Permalink
Browse files

stderr can now be mocked like stdout in ui_spec

  • Loading branch information...
1 parent c2f4e67 commit 405ebb088fb752e24aedc5bcf4716ebf276d0815 @kballard kballard committed May 27, 2008
Showing with 12 additions and 0 deletions.
  1. +12 −0 spec/ui_spec.rb
View
@@ -343,6 +343,7 @@ def run
invoke.call
end
@stdout_mock.invoke unless @stdout_mock.nil?
+ @stderr_mock.invoke unless @stderr_mock.nil?
end
def setup_remote(remote, options = {:user => nil, :project => "project"})
@@ -383,6 +384,17 @@ def stdout
@stdout_mock
end
+ def stderr
+ if @stderr_mock.nil?
+ output = ""
+ @stderr_mock = DeferredMock.new(output)
+ STDERR.should_receive(:write).any_number_of_times do |str|
+ output << str
+ end
+ end
+ @stderr_mock
+ end
+
class DeferredMock
def initialize(obj = nil)
@obj = obj

0 comments on commit 405ebb0

Please sign in to comment.