aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource/test/abstract_unit.rb
diff options
context:
space:
mode:
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