Class: RSpec::RubyContentMatchers::HaveCall

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_for_generators/matchers/content/have_call.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method, args = nil) ⇒ HaveCall

Returns a new instance of HaveCall.



12
13
14
15
# File 'lib/rspec_for_generators/matchers/content/have_call.rb', line 12

def initialize(method, args = nil)
  @method = method.to_s
  @args = args
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



10
11
12
# File 'lib/rspec_for_generators/matchers/content/have_call.rb', line 10

def args
  @args
end

#methodObject (readonly)

Returns the value of attribute method.



10
11
12
# File 'lib/rspec_for_generators/matchers/content/have_call.rb', line 10

def method
  @method
end

Instance Method Details

#failure_messageObject



21
22
23
24
# File 'lib/rspec_for_generators/matchers/content/have_call.rb', line 21

def failure_message
  return "Expected there to be a call to #{method} with args #{args}, but there wasn't" if args
  "Expected there to be a call to #{method}, but there wasn't"
end

#matches?(content) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/rspec_for_generators/matchers/content/have_call.rb', line 17

def matches?(content)
  content =~ /#{method}\s+#{args_expr}/m
end

#negative_failure_messageObject



26
27
28
29
# File 'lib/rspec_for_generators/matchers/content/have_call.rb', line 26

def negative_failure_message                                      
  return "Did not expect there to be a call to #{method} with args #{args}, but there was" if args
  "Did not expect there to be a call to #{method}, but there was"
end