mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Require Mocha >= 0.9.3 which includes a MiniTest adapter
This commit is contained in:
parent
5d3712a81e
commit
e931012287
6 changed files with 13 additions and 65 deletions
|
@ -8,7 +8,7 @@ require 'yaml'
|
|||
require 'stringio'
|
||||
require 'test/unit'
|
||||
|
||||
gem 'mocha', '>= 0.9.0'
|
||||
gem 'mocha', '>= 0.9.3'
|
||||
require 'mocha'
|
||||
|
||||
begin
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'rubygems'
|
||||
require 'test/unit'
|
||||
|
||||
gem 'mocha', '>= 0.5.5'
|
||||
gem 'mocha', '>= 0.9.3'
|
||||
require 'mocha'
|
||||
|
||||
require 'active_model'
|
||||
|
|
|
@ -1,22 +1,18 @@
|
|||
require 'test/unit/testcase'
|
||||
require 'active_support/testing/setup_and_teardown'
|
||||
require 'active_support/testing/assertions'
|
||||
require 'active_support/testing/deprecation'
|
||||
require 'active_support/testing/declarative'
|
||||
|
||||
begin
|
||||
gem 'mocha', '>= 0.9.0'
|
||||
gem 'mocha', '>= 0.9.3'
|
||||
require 'mocha'
|
||||
|
||||
if defined?(MiniTest)
|
||||
require 'active_support/testing/mocha_minitest_adapter'
|
||||
end
|
||||
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
|
||||
|
||||
require 'test/unit/testcase'
|
||||
require 'active_support/testing/setup_and_teardown'
|
||||
require 'active_support/testing/assertions'
|
||||
require 'active_support/testing/deprecation'
|
||||
require 'active_support/testing/declarative'
|
||||
|
||||
module ActiveSupport
|
||||
class TestCase < ::Test::Unit::TestCase
|
||||
if defined? MiniTest
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
class MiniTest::Unit::TestCase
|
||||
include Mocha::Standalone
|
||||
|
||||
class MochaAssertionCounter
|
||||
def initialize(runner) @runner = runner end
|
||||
def increment; @runner.assertion_count += 1 end
|
||||
end
|
||||
|
||||
def run(runner)
|
||||
assertion_counter = MochaAssertionCounter.new(runner)
|
||||
result = '.'
|
||||
begin
|
||||
begin
|
||||
@passed = nil
|
||||
setup
|
||||
__send__ name
|
||||
mocha_verify(assertion_counter)
|
||||
@passed = true
|
||||
rescue Exception => e
|
||||
@passed = false
|
||||
result = runner.puke(self.class, self.name, e)
|
||||
ensure
|
||||
begin
|
||||
teardown
|
||||
rescue Exception => e
|
||||
result = runner.puke(self.class, self.name, e)
|
||||
end
|
||||
end
|
||||
ensure
|
||||
mocha_teardown
|
||||
end
|
||||
result
|
||||
end
|
||||
end
|
||||
|
||||
module Test
|
||||
module Unit
|
||||
remove_const :TestCase
|
||||
|
||||
class TestCase < MiniTest::Unit::TestCase
|
||||
include Test::Unit::Assertions
|
||||
def self.test_order; :sorted end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require 'rubygems'
|
||||
require 'test/unit'
|
||||
gem 'mocha', '>= 0.9.0'
|
||||
gem 'mocha', '>= 0.9.3'
|
||||
require 'mocha'
|
||||
|
||||
$:.unshift "#{File.dirname(__FILE__)}/../lib"
|
||||
|
|
|
@ -3,18 +3,15 @@ $:.unshift File.dirname(__FILE__) + "/../../actionpack/lib"
|
|||
$:.unshift File.dirname(__FILE__) + "/../lib"
|
||||
$:.unshift File.dirname(__FILE__) + "/../builtin/rails_info"
|
||||
|
||||
require 'rubygems'
|
||||
require 'test/unit'
|
||||
gem 'mocha', '>= 0.9.3'
|
||||
require 'mocha'
|
||||
require 'stringio'
|
||||
require 'active_support'
|
||||
|
||||
# Wrap tests that use Mocha and skip if unavailable.
|
||||
def uses_mocha(test_name)
|
||||
require 'rubygems'
|
||||
gem 'mocha', '>= 0.5.5'
|
||||
require 'mocha'
|
||||
yield
|
||||
rescue LoadError
|
||||
$stderr.puts "Skipping #{test_name} tests. `gem install mocha` and try again."
|
||||
end
|
||||
|
||||
if defined?(RAILS_ROOT)
|
||||
|
|
Loading…
Reference in a new issue