Class: Minitest::Substitute::Substitutor

Inherits:
Object
  • Object
show all
Defined in:
lib/minitest/substitute/substitutor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target, on:) ⇒ Substitutor

Returns a new instance of Substitutor.



9
10
11
# File 'lib/minitest/substitute/substitutor.rb', line 9

def initialize(target, on:)
  @target, @on = target, on
end

Instance Attribute Details

#on=(value) ⇒ Object (writeonly)

Sets the attribute on

Parameters:

  • value

    the value to set the attribute on to.



7
8
9
# File 'lib/minitest/substitute/substitutor.rb', line 7

def on=(value)
  @on = value
end

Instance Method Details

#commitObject



18
19
20
21
# File 'lib/minitest/substitute/substitutor.rb', line 18

def commit
  @original = get
  set @substitute
end

#rollbackObject



23
24
25
# File 'lib/minitest/substitute/substitutor.rb', line 23

def rollback
  set @original
end

#substitute(value) ⇒ Object



13
14
15
16
# File 'lib/minitest/substitute/substitutor.rb', line 13

def substitute(value)
  @substitute = value unless instance_variable_defined? :@substitute
  self
end