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

#contentObject (readonly)

Returns the value of attribute content.



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

def content
  @content
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



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

def failure_message
  puts "Content: #{content}" if RSpec::Generator.debug?      
  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
20
# File 'lib/rspec_for_generators/matchers/content/have_call.rb', line 17

def matches?(content)
  @content = content
  (content =~ /#{method}#{args_expr}/m) != nil
end

#negative_failure_messageObject



28
29
30
31
32
# File 'lib/rspec_for_generators/matchers/content/have_call.rb', line 28

def negative_failure_message               
  puts "Content: #{content}" if RSpec::Generator.debug?                             
  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