aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource/test/abstract_unit.rb
diff options
context:
space:
mode:
authorCheah Chu Yeow <chuyeow@gmail.com>2008-04-16 18:39:19 +0800
committerMichael Koziarski <michael@koziarski.com>2008-04-22 09:30:56 +1200
commitcf32baf915442ffe153ec0e4d8148f147776c30a (patch)
tree9405205f0ab6ddfceb49043206aa034f33a53cc1 /activeresource/test/abstract_unit.rb
parent105910429d5873dce677ef32eef5f705e0625d86 (diff)
downloadrails-cf32baf915442ffe153ec0e4d8148f147776c30a.tar.gz
rails-cf32baf915442ffe153ec0e4d8148f147776c30a.tar.bz2
rails-cf32baf915442ffe153ec0e4d8148f147776c30a.zip
Rescue from Timeout::Error in ActiveResource::Connection.
Signed-off-by: Michael Koziarski <michael@koziarski.com>
Diffstat (limited to 'activeresource/test/abstract_unit.rb')
-rw-r--r--activeresource/test/abstract_unit.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/activeresource/test/abstract_unit.rb b/activeresource/test/abstract_unit.rb
index db1e0b9535..615a6d9222 100644
--- a/activeresource/test/abstract_unit.rb
+++ b/activeresource/test/abstract_unit.rb
@@ -7,4 +7,16 @@ require 'active_resource/http_mock'
$:.unshift "#{File.dirname(__FILE__)}/../test"
require 'setter_trap'
-ActiveResource::Base.logger = Logger.new("#{File.dirname(__FILE__)}/debug.log") \ No newline at end of file
+ActiveResource::Base.logger = Logger.new("#{File.dirname(__FILE__)}/debug.log")
+
+# Wrap tests that use Mocha and skip if unavailable.
+def uses_mocha(test_name)
+ unless Object.const_defined?(:Mocha)
+ require 'mocha'
+ require 'stubba'
+ end
+ yield
+rescue LoadError => load_error
+ raise unless load_error.message =~ /mocha/i
+ $stderr.puts "Skipping #{test_name} tests. `gem install mocha` and try again."
+end \ No newline at end of file