Sha256: f06f02c86291f5f044f4643e7ae0aba0ef21b60a5e48204d4422149c687df772
Contents?: true
Size: 1.89 KB
Versions: 8
Compression:
Stored size: 1.89 KB
Contents
require File.expand_path('../acceptance_test_helper', __FILE__) require 'mocha/ruby_version' class PrependTest < Mocha::TestCase include AcceptanceTest def setup setup_acceptance_test end def teardown teardown_acceptance_test end if Mocha::RUBY_V2_PLUS module Mod1 def my_method super + ' World' end end module Mod2 def my_method super + ' Wide' end end class Klass1 prepend Mod1 prepend Mod2 def my_method 'Hello' end end class Klass2 class << self prepend Mod1 prepend Mod2 def my_method 'Hello' end end end def test_stubbing_any_instance_with_multiple_prepended_methods assert_snapshot_unchanged(Klass1) do test_result = run_as_test do Klass1.any_instance.stubs(:my_method).returns('Bye World') assert_equal 'Bye World', Klass1.new.my_method end assert_passed(test_result) end assert_equal 'Hello World Wide', Klass1.new.my_method end def test_stubbing_instance_with_multiple_prepended_methods object = Klass1.new assert_snapshot_unchanged(object) do test_result = run_as_test do object.stubs(:my_method).returns('Bye World') assert_equal 'Bye World', object.my_method assert_equal 'Hello World Wide', Klass1.new.my_method end assert_passed(test_result) end assert_equal 'Hello World Wide', object.my_method end def test_stubbing_a_prepended_class_method assert_snapshot_unchanged(Klass2) do test_result = run_as_test do Klass2.stubs(:my_method).returns('Bye World') assert_equal 'Bye World', Klass2.my_method end assert_passed(test_result) end assert_equal 'Hello World Wide', Klass2.my_method end end end
Version data entries
8 entries across 8 versions & 1 rubygems