From 089da2e54db54c021681af1a31aadc2c0e15c1e0 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 3 Jul 2012 14:21:53 -0700 Subject: hook mocha in through m/t before_setup, after_teardown hooks --- activesupport/lib/active_support/test_case.rb | 4 +++- .../lib/active_support/testing/mocha_module.rb | 22 ++++++++++++++++++++++ .../lib/active_support/testing/mochaing.rb | 7 ------- 3 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 activesupport/lib/active_support/testing/mocha_module.rb delete mode 100644 activesupport/lib/active_support/testing/mochaing.rb (limited to 'activesupport') diff --git a/activesupport/lib/active_support/test_case.rb b/activesupport/lib/active_support/test_case.rb index e2b46a235a..b6abc3b561 100644 --- a/activesupport/lib/active_support/test_case.rb +++ b/activesupport/lib/active_support/test_case.rb @@ -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 diff --git a/activesupport/lib/active_support/testing/mocha_module.rb b/activesupport/lib/active_support/testing/mocha_module.rb new file mode 100644 index 0000000000..ed2942d23a --- /dev/null +++ b/activesupport/lib/active_support/testing/mocha_module.rb @@ -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 diff --git a/activesupport/lib/active_support/testing/mochaing.rb b/activesupport/lib/active_support/testing/mochaing.rb deleted file mode 100644 index 4ad75a6681..0000000000 --- a/activesupport/lib/active_support/testing/mochaing.rb +++ /dev/null @@ -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 \ No newline at end of file -- cgit v1.2.3