diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-07-03 14:21:53 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-07-03 14:28:28 -0700 |
commit | 089da2e54db54c021681af1a31aadc2c0e15c1e0 (patch) | |
tree | 93d6df028dc5633e0e73ab098afe276057352e68 /activesupport | |
parent | 1337d51f44496d3279f9daf53961777f50b1910d (diff) | |
download | rails-089da2e54db54c021681af1a31aadc2c0e15c1e0.tar.gz rails-089da2e54db54c021681af1a31aadc2c0e15c1e0.tar.bz2 rails-089da2e54db54c021681af1a31aadc2c0e15c1e0.zip |
hook mocha in through m/t before_setup, after_teardown hooks
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/test_case.rb | 4 | ||||
-rw-r--r-- | activesupport/lib/active_support/testing/mocha_module.rb | 22 | ||||
-rw-r--r-- | activesupport/lib/active_support/testing/mochaing.rb | 7 |
3 files changed, 25 insertions, 8 deletions
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 |