Sha256: 737a1c22c2d68e7044c89182dc9905c05e20d8c56acb3d95f30cb0c233f68b6f

Contents?: true

Size: 1.39 KB

Versions: 17

Compression:

Stored size: 1.39 KB

Contents

require File.expand_path('../acceptance_test_helper', __FILE__)
require 'mocha/setup'

class StubbingMethodAcceptingBlockParameterTest < Mocha::TestCase

  include AcceptanceTest

  def setup
    setup_acceptance_test
  end

  def teardown
    teardown_acceptance_test
  end

  def test_stubbing_class_method_accepting_block_parameter_should_restore_original_method
    klass = Class.new do
      def self.my_class_method(&block); block.call; end
    end
    test_result = run_as_test do
      klass.stubs(:my_class_method)
    end
    assert_passed(test_result)
    assert_equal :return_value, klass.my_class_method { :return_value }
  end

  def test_stubbing_instance_method_accepting_block_parameter_should_restore_original_method
    instance = Class.new do
      def my_instance_method(&block); block.call; end
    end.new
    test_result = run_as_test do
      instance.stubs(:my_instance_method)
    end
    assert_passed(test_result)
    assert_equal :return_value, instance.my_instance_method { :return_value }
  end

  def test_stubbing_any_instance_method_accepting_block_parameter_should_restore_original_method
    klass = Class.new do
      def my_instance_method(&block); block.call; end
    end
    test_result = run_as_test do
      klass.any_instance.stubs(:my_instance_method)
    end
    assert_passed(test_result)
    assert_equal :return_value, klass.new.my_instance_method { :return_value }
  end
end

Version data entries

17 entries across 14 versions & 4 rubygems

Version Path
mocha-1.6.0 test/acceptance/stubbing_method_accepting_block_parameter_test.rb
mocha-1.5.0 test/acceptance/stubbing_method_accepting_block_parameter_test.rb
mocha-1.4.0 test/acceptance/stubbing_method_accepting_block_parameter_test.rb
mocha-1.3.0 test/acceptance/stubbing_method_accepting_block_parameter_test.rb
mocha-1.2.1 test/acceptance/stubbing_method_accepting_block_parameter_test.rb
mocha-1.2.0 test/acceptance/stubbing_method_accepting_block_parameter_test.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/mocha-1.0.0/test/acceptance/stubbing_method_accepting_block_parameter_test.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/mocha-1.0.0/test/acceptance/stubbing_method_accepting_block_parameter_test.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/mocha-1.0.0/test/acceptance/stubbing_method_accepting_block_parameter_test.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/mocha-1.0.0/test/acceptance/stubbing_method_accepting_block_parameter_test.rb
mocha-1.1.0 test/acceptance/stubbing_method_accepting_block_parameter_test.rb
mocha-1.0.0 test/acceptance/stubbing_method_accepting_block_parameter_test.rb
mocha-1.0.0.alpha test/acceptance/stubbing_method_accepting_block_parameter_test.rb
tnargav-1.3.3 vendor/bundle/ruby/1.9.1/gems/mocha-0.14.0/test/acceptance/stubbing_method_accepting_block_parameter_test.rb
challah-1.0.0 vendor/bundle/gems/mocha-0.14.0/test/acceptance/stubbing_method_accepting_block_parameter_test.rb
tnargav-1.2.3 vendor/bundle/ruby/1.9.1/gems/mocha-0.14.0/test/acceptance/stubbing_method_accepting_block_parameter_test.rb
mocha-0.14.0 test/acceptance/stubbing_method_accepting_block_parameter_test.rb