Class: Test::Unit::TestCase
- Inherits:
-
Object
- Object
- Test::Unit::TestCase
- Defined in:
- lib/rscm/mockit.rb
Overview
:nodoc:
Class Method Summary collapse
Instance Method Summary collapse
- #new_mock ⇒ Object
- #setup_with_mocks ⇒ Object (also: #setup)
- #teardown_with_mocks ⇒ Object (also: #teardown)
Class Method Details
.method_added(method) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rscm/mockit.rb', line 18 def self.method_added(method) case method.to_s when 'setup' unless method_defined?(:setup_without_mocks) alias_method :setup_without_mocks, :setup define_method(:setup) do setup_with_mocks setup_without_mocks end end when 'teardown' unless method_defined?(:teardown_without_mocks) alias_method :teardown_without_mocks, :teardown define_method(:teardown) do teardown_without_mocks teardown_with_mocks end end end end |
Instance Method Details
#new_mock ⇒ Object
39 40 41 42 43 44 |
# File 'lib/rscm/mockit.rb', line 39 def new_mock mock = MockIt::Mock.new @to_verify = [] unless @to_verify @to_verify << mock mock end |
#setup_with_mocks ⇒ Object Also known as: setup
6 7 8 |
# File 'lib/rscm/mockit.rb', line 6 def setup_with_mocks @to_verify = [] end |
#teardown_with_mocks ⇒ Object Also known as: teardown
11 12 13 14 15 |
# File 'lib/rscm/mockit.rb', line 11 def teardown_with_mocks if(@test_passed && @to_verify) @to_verify.each{|m| m.__verify} end end |