hook mocha in through m/t before_setup, after_teardown hooks

This commit is contained in:
Aaron Patterson 2012-07-03 14:21:53 -07:00
parent 1337d51f44
commit 089da2e54d
4 changed files with 26 additions and 9 deletions

View File

@ -9,7 +9,7 @@ else
end
gem 'minitest', '~> 3.2.0'
gem 'mocha', '>= 0.11.2'
gem 'mocha', '>= 0.11.2', :require => false
gem 'rack-test', github: "brynary/rack-test"
gem 'bcrypt-ruby', '~> 3.0.0'
gem 'jquery-rails'

View File

@ -4,12 +4,14 @@ require 'active_support/testing/assertions'
require 'active_support/testing/deprecation'
require 'active_support/testing/declarative'
require 'active_support/testing/isolation'
require 'active_support/testing/mochaing'
require 'active_support/testing/mocha_module'
require 'active_support/core_ext/kernel/reporting'
module ActiveSupport
class TestCase < ::MiniTest::Spec
include ActiveSupport::Testing::MochaModule
if MiniTest::Unit::VERSION < '2.6.1'
class << self
alias :name :to_s

View File

@ -0,0 +1,22 @@
module ActiveSupport
module Testing
module MochaModule
begin
require 'mocha_standalone'
include Mocha::API
def before_setup
mocha_setup
super
end
def after_teardown
super
mocha_verify
mocha_teardown
end
rescue LoadError
end
end
end
end

View File

@ -1,7 +0,0 @@
begin
silence_warnings { require 'mocha' }
rescue LoadError
# Fake Mocha::ExpectationError so we can rescue it in #run. Bleh.
Object.const_set :Mocha, Module.new
Mocha.const_set :ExpectationError, Class.new(StandardError)
end