Sha256: 6b9a98cf8dd83b6a481292d2c9d781b01051d68bc828a7cdc71a27e906a0f51d
Contents?: true
Size: 1.02 KB
Versions: 2
Compression:
Stored size: 1.02 KB
Contents
module NotAMock # Instances returned by Object.stub_instance are NotAMock::Stub objects. # These do their best to masquerade as the real thing. class Stub # This is normall only called from Object.stub_instance. def initialize(stubbed_class, methods = {}) #:nodoc: @stubbed_class = stubbed_class methods.each do |method, result| self.meta_eval do define_method(method) { result } end track_method(method) end end # Returns "Stub StubbedClass". def inspect "Stub #{@stubbed_class.to_s}" end # Returns true if the class of the stubbed object or one of its superclasses is klass. def is_a?(klass) @stubbed_class.ancestors.include?(klass) end alias_method :kind_of?, :is_a? # Returns true if the class of the stubbed object is klass. def instance_of?(klass) @stubbed_class == klass end # Returns the class of the stubbed object. def class @stubbed_class end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
not_a_mock-1.0.1 | lib/not_a_mock/stub.rb |
not_a_mock-1.0.0 | lib/not_a_mock/stub.rb |