Class: Surrogate::RSpec::AbstractFailureMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/surrogate/rspec/abstract_failure_message.rb

Defined Under Namespace

Classes: ArgsInspector

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method_name, invocations, with_filter, times_predicate) ⇒ AbstractFailureMessage

Returns a new instance of AbstractFailureMessage.



22
23
24
25
26
27
# File 'lib/surrogate/rspec/abstract_failure_message.rb', line 22

def initialize(method_name, invocations, with_filter, times_predicate)
  self.method_name     = method_name
  self.invocations     = invocations
  self.with_filter     = with_filter
  self.times_predicate = times_predicate
end

Instance Attribute Details

#invocationsObject

Returns the value of attribute invocations.



20
21
22
# File 'lib/surrogate/rspec/abstract_failure_message.rb', line 20

def invocations
  @invocations
end

#method_nameObject

Returns the value of attribute method_name.



20
21
22
# File 'lib/surrogate/rspec/abstract_failure_message.rb', line 20

def method_name
  @method_name
end

#times_predicateObject

Returns the value of attribute times_predicate.



20
21
22
# File 'lib/surrogate/rspec/abstract_failure_message.rb', line 20

def times_predicate
  @times_predicate
end

#with_filterObject

Returns the value of attribute with_filter.



20
21
22
# File 'lib/surrogate/rspec/abstract_failure_message.rb', line 20

def with_filter
  @with_filter
end

Instance Method Details

#expected_invocationObject



46
47
48
# File 'lib/surrogate/rspec/abstract_failure_message.rb', line 46

def expected_invocation
  with_filter.expected_invocation
end

#expected_times_invokedObject



54
55
56
# File 'lib/surrogate/rspec/abstract_failure_message.rb', line 54

def expected_times_invoked
  times_predicate.expected_times_invoked
end

#get_messageObject



29
30
31
# File 'lib/surrogate/rspec/abstract_failure_message.rb', line 29

def get_message
  raise "I should have been overridden"
end

#inspect_arguments(arguments) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/surrogate/rspec/abstract_failure_message.rb', line 37

def inspect_arguments(arguments)
  # can we fix this as soon as an array enters the system instead of catching it here?
  if arguments.kind_of? Invocation
    ArgsInspector.inspect arguments
  else
    ArgsInspector.inspect Invocation.new arguments
  end
end

#times_invokedObject



33
34
35
# File 'lib/surrogate/rspec/abstract_failure_message.rb', line 33

def times_invoked
  invocations.size
end

#times_msg(n) ⇒ Object



50
51
52
# File 'lib/surrogate/rspec/abstract_failure_message.rb', line 50

def times_msg(n)
  "#{n} time#{'s' unless n == 1}"
end