Class: Stendhal::Mocks::TestDouble

Inherits:
Object
  • Object
show all
Defined in:
lib/stendhal/mocks/test_double.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, stubs = {}) ⇒ TestDouble

Returns a new instance of TestDouble.



7
8
9
10
# File 'lib/stendhal/mocks/test_double.rb', line 7

def initialize(name, stubs = {}) 
  @name = name
  assign_stubs(stubs)
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/stendhal/mocks/test_double.rb', line 5

def name
  @name
end

Instance Method Details

#assign_stubs(stubs) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/stendhal/mocks/test_double.rb', line 12

def assign_stubs(stubs)
  stubs.each_pair do |k,v|
    (class << self;self;end).send(:define_method,k.to_sym)  do |*args|
      v 
    end
  end
end