Sha256: f5dd3b1f00f11e2c7399189ea54225e1f1413656143f43397dc25625171614b6

Contents?: true

Size: 575 Bytes

Versions: 2

Compression:

Stored size: 575 Bytes

Contents

class Factory 
  class Proxy
    class Stub < Proxy #:nodoc:
      def initialize(klass)
        @mock = Object.new
      end
      
      def get(attribute)
        @mock.send(attribute)
      end
      
      def set(attribute, value)
        unless @mock.respond_to?("attribute=")
          class << @mock; self end.send(:attr_accessor, attribute)
        end
        @mock.send("#{attribute}=", value)
      end
      
      def associate(name, factory, attributes)
        set(name, nil)
      end
      
      def result
        @mock      
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
thoughtbot-factory_girl-1.2.0 lib/factory_girl/proxy/stub.rb
factory_girl-1.2.0 lib/factory_girl/proxy/stub.rb