summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/app_test.rb6
-rw-r--r--test/ext/capture_output.rb23
-rw-r--r--test/test_helper.rb26
3 files changed, 29 insertions, 26 deletions
diff --git a/test/app_test.rb b/test/app_test.rb
index d8f2324..68e3782 100644
--- a/test/app_test.rb
+++ b/test/app_test.rb
@@ -42,7 +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
+ assert_match /connection failed/i, error_output
end
def test_configure_on_auth_failure
@@ -53,7 +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
+ assert_match /unable to authenticate/i, error_output
end
def test_api_failure
@@ -61,7 +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
+ assert_match /API failure/i, error_output
end
end
diff --git a/test/ext/capture_output.rb b/test/ext/capture_output.rb
new file mode 100644
index 0000000..6fef849
--- /dev/null
+++ b/test/ext/capture_output.rb
@@ -0,0 +1,23 @@
+module CaptureOutput
+ def before_setup
+ super
+ $stderr = @stderr = StringIO.new
+ $stdout = @stdout = StringIO.new
+ end
+ def after_teardown
+ super
+ $stderr = STDERR
+ $stdout = STDOUT
+ end
+ def error_output
+ @stderr.string
+ end
+ def standard_output
+ @stdout.string
+ end
+end
+class HCl::TestCase < MiniTest::Unit::TestCase
+ include CaptureOutput
+end
+
+
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 8e1910a..42a072c 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -21,33 +21,13 @@ end
# override the default hcl dir
ENV['HCL_DIR'] = File.dirname(__FILE__)+"/dot_hcl"
-require 'hcl'
+require 'hcl'
require 'minitest/autorun'
require 'mocha/setup'
require 'fileutils'
require 'fakeweb'
-module CaptureOutput
- def before_setup
- super
- $stderr = @stderr = StringIO.new
- $stdout = @stdout = StringIO.new
- end
- def after_teardown
- super
- $stderr = STDERR
- $stdout = STDOUT
- end
- def error
- @stderr.string
- end
- def output
- @stdout.string
- end
-end
-class HCl::TestCase < MiniTest::Unit::TestCase
- include CaptureOutput
-end
-
+# require test extensions/helpers
+Dir[File.dirname(__FILE__) + '/ext/*.rb'].each { |ext| require ext }