Class: RSpec::RubyContentMatchers::HaveCalls

Inherits:
HaveCall show all
Defined in:
lib/code_spec/matchers/have_calls.rb

Constant Summary

Constants inherited from RSpec::RubyContentMatcher

RSpec::RubyContentMatcher::ANY_GROUP, RSpec::RubyContentMatcher::LPAR, RSpec::RubyContentMatcher::OPT_ARGS, RSpec::RubyContentMatcher::OPT_SPACES, RSpec::RubyContentMatcher::Q_ANY_GROUP, RSpec::RubyContentMatcher::RPAR, RSpec::RubyContentMatcher::SPACES

Instance Attribute Summary collapse

Attributes inherited from HaveCall

#content, #dot, #method_name

Attributes inherited from RSpec::RubyContentMatcher

#alt_end, #content, #content_matches, #end_option

Instance Method Summary collapse

Methods inherited from HaveCall

#failure_message, #negative_failure_message

Methods inherited from RSpec::RubyContentMatcher

#any_args_expr, #args_expr, #args_msg, #comment_end, #debug, #debug?, #debug_content, #display, #display_content, #end_expr, #failure_message, #get_expr, #handle_result, #index, #indexes, #is_match?, #main_expr, #negative_failure_message, #opt

Constructor Details

#initialize(*calls) ⇒ HaveCalls

Returns a new instance of HaveCalls.



5
6
7
8
9
10
11
12
# File 'lib/code_spec/matchers/have_calls.rb', line 5

def initialize(*calls)
  case calls.first
  when Array, Hash
    @calls = calls.first
  else    
    @calls = calls
  end
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



3
4
5
# File 'lib/code_spec/matchers/have_calls.rb', line 3

def args
  @args
end

#callsObject (readonly)

Returns the value of attribute calls.



3
4
5
# File 'lib/code_spec/matchers/have_calls.rb', line 3

def calls
  @calls
end

#methodObject (readonly)

Returns the value of attribute method.



3
4
5
# File 'lib/code_spec/matchers/have_calls.rb', line 3

def method
  @method
end

Instance Method Details

#matches?(content) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
20
21
22
# File 'lib/code_spec/matchers/have_calls.rb', line 14

def matches?(content)
  super
  case calls
  when Array
    do_list
  when Hash
    do_hash
  end
end