Sha256: 31af2ee6f057a8eea6386a4c1a28acc935cfdd596fa203a122b32d790906da20

Contents?: true

Size: 1.2 KB

Versions: 15

Compression:

Stored size: 1.2 KB

Contents

require File.expand_path('../../test_helper', __FILE__)
require 'mocha/object_methods'
require 'mocha/mock'
require 'mocha/expectation_error_factory'

class ObjectMethodsTest < Mocha::TestCase

  def setup
    @object = Object.new.extend(Mocha::ObjectMethods)
  end

  def test_should_build_mocha_referring_to_self
    mocha = @object.mocha
    assert_not_nil mocha
    assert mocha.is_a?(Mocha::Mock)
    assert_equal @object.mocha_inspect, mocha.mocha_inspect
  end

  def test_should_reuse_existing_mocha
    mocha_1 = @object.mocha
    mocha_2 = @object.mocha
    assert_equal mocha_1, mocha_2
  end

  def test_should_reset_mocha
    assert_nil @object.reset_mocha
  end

  def test_should_use_stubba_instance_method_for_object
    assert_equal Mocha::InstanceMethod, Object.new.stubba_method
  end

  def test_should_stub_self_for_object
    assert_equal @object, @object.stubba_object
  end

  def test_nobody_expects_the_spanish_inquisition
    assert_raise(Mocha::ExpectationErrorFactory.exception_class) { @object.expects(:the_spanish_inquisition) }
  end

  def test_should_alias_object_method
    klass = Class.new { def self.method_x; end }
    assert_equal klass._method(:method_x), klass.method(:method_x)
  end

end

Version data entries

15 entries across 12 versions & 4 rubygems

Version Path
mocha-1.4.0 test/unit/object_methods_test.rb
mocha-1.3.0 test/unit/object_methods_test.rb
mocha-1.2.1 test/unit/object_methods_test.rb
mocha-1.2.0 test/unit/object_methods_test.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/mocha-1.0.0/test/unit/object_methods_test.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/mocha-1.0.0/test/unit/object_methods_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/unit/object_methods_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/unit/object_methods_test.rb
mocha-1.1.0 test/unit/object_methods_test.rb
mocha-1.0.0 test/unit/object_methods_test.rb
mocha-1.0.0.alpha test/unit/object_methods_test.rb
tnargav-1.3.3 vendor/bundle/ruby/1.9.1/gems/mocha-0.14.0/test/unit/object_methods_test.rb
challah-1.0.0 vendor/bundle/gems/mocha-0.14.0/test/unit/object_methods_test.rb
tnargav-1.2.3 vendor/bundle/ruby/1.9.1/gems/mocha-0.14.0/test/unit/object_methods_test.rb
mocha-0.14.0 test/unit/object_methods_test.rb