diff options
| author | Zack Hobson | 2013-12-10 15:40:17 -0800 | 
|---|---|---|
| committer | Zack Hobson | 2013-12-10 15:40:17 -0800 | 
| commit | 03aaebeac787a885fb82ce1745eb6c3d2aa78ef1 (patch) | |
| tree | 58576199d38ce0948aa0003ca5d279fbef9db10a | |
| parent | c9d603a791e07e4e5b5dbd07cd7c5d1c27115d18 (diff) | |
| download | hcl-03aaebeac787a885fb82ce1745eb6c3d2aa78ef1.tar.bz2 | |
capture test output
| -rw-r--r-- | test/app_test.rb | 3 | ||||
| -rw-r--r-- | test/test_helper.rb | 10 | 
2 files changed, 11 insertions, 2 deletions
| diff --git a/test/app_test.rb b/test/app_test.rb index c9496c0..d8f2324 100644 --- a/test/app_test.rb +++ b/test/app_test.rb @@ -42,6 +42,7 @@ class AppTest < HCl::TestCase      app.expects(:show).raises(SocketError)      app.expects(:exit).with(1)      app.process_args('show').run +    assert_match /connection failed/i, error    end    def test_configure_on_auth_failure @@ -52,6 +53,7 @@ class AppTest < HCl::TestCase      app.expects(:write_config).then(configured.is(true))      app.expects(:show).when(configured.is(true))      app.process_args('show').run +    assert_match /unable to authenticate/i, error    end    def test_api_failure @@ -59,6 +61,7 @@ class AppTest < HCl::TestCase      app.expects(:show).raises(HCl::TimesheetResource::Failure)      app.expects(:exit).with(1)      app.process_args('show').run +    assert_match /API failure/i, error    end  end diff --git a/test/test_helper.rb b/test/test_helper.rb index 2fe445e..8e1910a 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -28,7 +28,7 @@ require 'mocha/setup'  require 'fileutils'  require 'fakeweb' -module IgnoreStderr +module CaptureOutput    def before_setup      super      $stderr = @stderr = StringIO.new @@ -39,9 +39,15 @@ module IgnoreStderr      $stderr = STDERR      $stdout = STDOUT    end +  def error +    @stderr.string +  end +  def output +    @stdout.string +  end  end  class HCl::TestCase < MiniTest::Unit::TestCase -  include IgnoreStderr +  include CaptureOutput  end | 
