Class: RSpec::RubyContentMatchers::HaveComment
- Inherits:
-
RSpec::RubyContentMatcher
- Object
- RSpec::RubyContentMatcher
- RSpec::RubyContentMatchers::HaveComment
- Defined in:
- lib/code_spec/matchers/have_comment.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
-
#comment ⇒ Object
Returns the value of attribute comment.
Attributes inherited from RSpec::RubyContentMatcher
#alt_end, #content, #content_matches, #end_option
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(comment) ⇒ HaveComment
constructor
A new instance of HaveComment.
- #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, #display, #display_content, #end_expr, #get_expr, #handle_result, #index, #indexes, #is_match?, #opt
Constructor Details
#initialize(comment) ⇒ HaveComment
Returns a new instance of HaveComment.
5 6 7 |
# File 'lib/code_spec/matchers/have_comment.rb', line 5 def initialize comment @comment = comment end |
Instance Attribute Details
#comment ⇒ Object
Returns the value of attribute comment.
3 4 5 |
# File 'lib/code_spec/matchers/have_comment.rb', line 3 def comment @comment end |
Instance Method Details
#failure_message ⇒ Object
14 15 16 17 |
# File 'lib/code_spec/matchers/have_comment.rb', line 14 def super display "Expected there to be the comment '# #{comment}'" end |
#matches?(content) ⇒ Boolean
9 10 11 12 |
# File 'lib/code_spec/matchers/have_comment.rb', line 9 def matches?(content) @content = content (content =~ /#{main_expr}/) end |
#negative_failure_message ⇒ Object
19 20 21 22 |
# File 'lib/code_spec/matchers/have_comment.rb', line 19 def super display "Did not expect there to be the comment '# #{comment}'" end |