Sha256: e80c9c1d2b085590f3ba53712312d3e56d4825afd0616ea3d043fc9fdb43f54b

Contents?: true

Size: 1.39 KB

Versions: 32

Compression:

Stored size: 1.39 KB

Contents

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

class StubbingMethodAcceptingBlockParameterTest < Test::Unit::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

32 entries across 27 versions & 3 rubygems

Version Path
mocha-0.12.3 test/acceptance/stubbing_method_accepting_block_parameter_test.rb
challah-0.7.0.pre vendor/bundle/gems/mocha-0.12.2/test/acceptance/stubbing_method_accepting_block_parameter_test.rb
mocha-0.12.2 test/acceptance/stubbing_method_accepting_block_parameter_test.rb
mocha-0.12.1 test/acceptance/stubbing_method_accepting_block_parameter_test.rb
mocha-0.12.0 test/acceptance/stubbing_method_accepting_block_parameter_test.rb
challah-0.6.2 vendor/bundle/gems/mocha-0.11.4/test/acceptance/stubbing_method_accepting_block_parameter_test.rb
challah-0.6.1 vendor/bundle/gems/mocha-0.11.4/test/acceptance/stubbing_method_accepting_block_parameter_test.rb
challah-0.6.0 vendor/bundle/gems/mocha-0.11.4/test/acceptance/stubbing_method_accepting_block_parameter_test.rb
mocha-0.11.4 test/acceptance/stubbing_method_accepting_block_parameter_test.rb
mocha-0.11.3 test/acceptance/stubbing_method_accepting_block_parameter_test.rb
mocha-0.11.2 test/acceptance/stubbing_method_accepting_block_parameter_test.rb
mocha-0.11.1 test/acceptance/stubbing_method_accepting_block_parameter_test.rb