Class: RSpec::RubyContentMatchers::HaveCall
- Inherits:
-
RSpec::RubyContentMatcher
- Object
- RSpec::RubyContentMatcher
- RSpec::RubyContentMatchers::HaveCall
- Defined in:
- lib/code_spec/matchers/have_call.rb
Direct Known Subclasses
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
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#dot ⇒ Object
readonly
Returns the value of attribute dot.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
Attributes inherited from RSpec::RubyContentMatcher
#alt_end, #content_matches, #end_option
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(method, options = {}) ⇒ HaveCall
constructor
A new instance of HaveCall.
- #matches?(content) ⇒ Boolean
- #negative_failure_message ⇒ Object
Methods inherited from RSpec::RubyContentMatcher
#any_args_expr, #args_expr, #args_msg, #comment_end, #debug, #debug?, #debug_content, #end_expr, #get_expr, #handle_result, #index, #indexes, #is_match?, #main_expr, #opt
Constructor Details
#initialize(method, options = {}) ⇒ HaveCall
Returns a new instance of HaveCall.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/code_spec/matchers/have_call.rb', line 12 def initialize(method, = {}) @method = method.to_s @args = case when Hash [:args] else end @dot = [:dot] end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
10 11 12 |
# File 'lib/code_spec/matchers/have_call.rb', line 10 def args @args end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
10 11 12 |
# File 'lib/code_spec/matchers/have_call.rb', line 10 def content @content end |
#dot ⇒ Object (readonly)
Returns the value of attribute dot.
10 11 12 |
# File 'lib/code_spec/matchers/have_call.rb', line 10 def dot @dot end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
10 11 12 |
# File 'lib/code_spec/matchers/have_call.rb', line 10 def method @method end |
Instance Method Details
#failure_message ⇒ Object
37 38 39 40 |
# File 'lib/code_spec/matchers/have_call.rb', line 37 def super "Expected there to be a call to #{method}#{args_msg}, but there wasn't" end |
#matches?(content) ⇒ Boolean
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/code_spec/matchers/have_call.rb', line 23 def matches?(content) @content = content has_def = (content =~ /def(.*)#{method}/) expr = if has_def || dot == :form /#{dot_expr}#{method}#{args_expr}/m else /#{dot_expr}?#{method}#{args_expr}/m end debug "expr = #{expr}" debug "content = %{#{content}}" debug "content =~ #{expr}" (content =~ expr) end |
#negative_failure_message ⇒ Object
42 43 44 45 |
# File 'lib/code_spec/matchers/have_call.rb', line 42 def super "Did not expect there to be a call to #{method}#{args_msg}, but there was" end |