mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Update uses_mocha in ActionMailer and ActiveResource
This commit is contained in:
parent
8c2e839e5a
commit
b74b97fef5
2 changed files with 27 additions and 15 deletions
|
@ -30,12 +30,20 @@ class Net::SMTP
|
|||
end
|
||||
end
|
||||
|
||||
# Wrap tests that use Mocha and skip if unavailable.
|
||||
def uses_mocha(test_name)
|
||||
gem 'mocha', ">=0.9.0"
|
||||
def uses_gem(gem_name, test_name, version = '> 0')
|
||||
require 'rubygems'
|
||||
gem gem_name.to_s, version
|
||||
require gem_name.to_s
|
||||
yield
|
||||
rescue Gem::LoadError
|
||||
$stderr.puts "Skipping #{test_name} tests (Mocha >= 0.5 is required). `gem install mocha` and try again."
|
||||
rescue LoadError
|
||||
$stderr.puts "Skipping #{test_name} tests. `gem install #{gem_name}` and try again."
|
||||
end
|
||||
|
||||
# Wrap tests that use Mocha and skip if unavailable.
|
||||
unless defined? uses_mocha
|
||||
def uses_mocha(test_name, &block)
|
||||
uses_gem('mocha', test_name, '>= 0.5.5', &block)
|
||||
end
|
||||
end
|
||||
|
||||
def set_delivery_method(delivery_method)
|
||||
|
|
|
@ -9,14 +9,18 @@ require 'setter_trap'
|
|||
|
||||
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
|
||||
def uses_gem(gem_name, test_name, version = '> 0')
|
||||
require 'rubygems'
|
||||
gem gem_name.to_s, version
|
||||
require gem_name.to_s
|
||||
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
|
||||
rescue LoadError
|
||||
$stderr.puts "Skipping #{test_name} tests. `gem install #{gem_name}` and try again."
|
||||
end
|
||||
|
||||
# Wrap tests that use Mocha and skip if unavailable.
|
||||
unless defined? uses_mocha
|
||||
def uses_mocha(test_name, &block)
|
||||
uses_gem('mocha', test_name, '>= 0.5.5', &block)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue