Class: RSpec::RubyContentMatchers::HaveMethods
- Inherits:
-
RSpec::RubyContentMatcher
- Object
- RSpec::RubyContentMatcher
- RSpec::RubyContentMatchers::HaveMethods
- Defined in:
- lib/code_spec/matchers/multi/have_methods.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
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#names ⇒ Object
readonly
Returns the value of attribute names.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from RSpec::RubyContentMatcher
#content, #content_matches, #end_option
Instance Method Summary collapse
- #failure_message ⇒ Object
- #index ⇒ Object
-
#initialize(*methods) ⇒ HaveMethods
constructor
A new instance of HaveMethods.
- #is_match?(content) ⇒ Boolean
- #matches?(content, &block) ⇒ Boolean
- #negative_failure_message ⇒ Object
Methods inherited from RSpec::RubyContentMatcher
#any_args_expr, #args_msg, #comment_end, #debug, #debug?, #debug_content, #display, #display_content, #end_expr, #get_expr, #handle_result, #indexes, #opt
Constructor Details
#initialize(*methods) ⇒ HaveMethods
Returns a new instance of HaveMethods.
12 13 14 15 16 17 |
# File 'lib/code_spec/matchers/multi/have_methods.rb', line 12 def initialize *methods = last_option methods @names = methods.to_strings @type = [:type] @args = [:args] end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
10 11 12 |
# File 'lib/code_spec/matchers/multi/have_methods.rb', line 10 def args @args end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
10 11 12 |
# File 'lib/code_spec/matchers/multi/have_methods.rb', line 10 def method @method end |
#names ⇒ Object (readonly)
Returns the value of attribute names.
10 11 12 |
# File 'lib/code_spec/matchers/multi/have_methods.rb', line 10 def names @names end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
10 11 12 |
# File 'lib/code_spec/matchers/multi/have_methods.rb', line 10 def type @type end |
Instance Method Details
#failure_message ⇒ Object
44 45 46 47 |
# File 'lib/code_spec/matchers/multi/have_methods.rb', line 44 def super "Expected there to be the #{class_msg} method #{method}, but there wasn't" end |
#index ⇒ Object
40 41 42 |
# File 'lib/code_spec/matchers/multi/have_methods.rb', line 40 def index 1 end |
#is_match?(content) ⇒ Boolean
32 33 34 35 36 37 38 |
# File 'lib/code_spec/matchers/multi/have_methods.rb', line 32 def is_match? content expr = get_expr(content) debug "match expression: #{expr}" match = (content =~ expr) @content_matches = [$1, $2, $3] match end |
#matches?(content, &block) ⇒ Boolean
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/code_spec/matchers/multi/have_methods.rb', line 19 def matches? content, &block return false if names.empty? @content = content names.each do |name| @method = name @end_option = name match = is_match? content return false if !match end true end |
#negative_failure_message ⇒ Object
49 50 51 52 |
# File 'lib/code_spec/matchers/multi/have_methods.rb', line 49 def super "Did not expect there to be the #{class_msg} method #{method}, but there was" end |