Class: Shoulda::Matchers::Doublespeak::MethodCall

Inherits:
Object
  • Object
show all
Defined in:
lib/shoulda/matchers/doublespeak/method_call.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ MethodCall

Returns a new instance of MethodCall.



9
10
11
12
13
14
15
16
17
# File 'lib/shoulda/matchers/doublespeak/method_call.rb', line 9

def initialize(args)
  @method_name = args.fetch(:method_name)
  @args = args.fetch(:args)
  @caller = args.fetch(:caller)
  @block = args[:block]
  @double = args[:double]
  @object = args[:object]
  @return_value = nil
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



7
8
9
# File 'lib/shoulda/matchers/doublespeak/method_call.rb', line 7

def args
  @args
end

#blockObject (readonly)

Returns the value of attribute block.



7
8
9
# File 'lib/shoulda/matchers/doublespeak/method_call.rb', line 7

def block
  @block
end

#callerObject (readonly)

Returns the value of attribute caller.



7
8
9
# File 'lib/shoulda/matchers/doublespeak/method_call.rb', line 7

def caller
  @caller
end

#doubleObject (readonly)

Returns the value of attribute double.



7
8
9
# File 'lib/shoulda/matchers/doublespeak/method_call.rb', line 7

def double
  @double
end

#method_nameObject (readonly)

Returns the value of attribute method_name.



7
8
9
# File 'lib/shoulda/matchers/doublespeak/method_call.rb', line 7

def method_name
  @method_name
end

#objectObject (readonly)

Returns the value of attribute object.



7
8
9
# File 'lib/shoulda/matchers/doublespeak/method_call.rb', line 7

def object
  @object
end

#return_valueObject

Returns the value of attribute return_value.



6
7
8
# File 'lib/shoulda/matchers/doublespeak/method_call.rb', line 6

def return_value
  @return_value
end

Instance Method Details

#==(other) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/shoulda/matchers/doublespeak/method_call.rb', line 25

def ==(other)
  other.is_a?(self.class) &&
    method_name == other.method_name &&
    args == other.args &&
    block == other.block &&
    double == other.double &&
    object == other.object
end

#inspectObject



38
39
40
# File 'lib/shoulda/matchers/doublespeak/method_call.rb', line 38

def inspect
  "#<#{self.class.name} #{to_hash.inspect}>"
end

#to_hashObject



34
35
36
# File 'lib/shoulda/matchers/doublespeak/method_call.rb', line 34

def to_hash
  { method_name: method_name, args: args }
end

#with_return_value(return_value) ⇒ Object



19
20
21
22
23
# File 'lib/shoulda/matchers/doublespeak/method_call.rb', line 19

def with_return_value(return_value)
  dup.tap do |call|
    call.return_value = return_value
  end
end