Sha256: 717e748d479d333e56aeb3c3b1178c2e0b5ac666520686aa7543f68f68c0e55c

Contents?: true

Size: 682 Bytes

Versions: 4

Compression:

Stored size: 682 Bytes

Contents

module RSpec::RubyContentMatchers
  class HaveComment < RSpec::RubyContentMatcher
    attr_accessor :comment

    def initialize comment
      @comment = comment
    end

    def matches?(content)
      @content = content                        
      (content =~ /#{main_expr}/)
    end
  
    def failure_message
      super
      display "Expected there to be the comment '# #{comment}'" 
    end 
    
    def negative_failure_message
      super
      display "Did not expect there to be the comment '# #{comment}'" 
    end

    protected
    
    def main_expr
      '\s*#\s*' + "#{comment}"
    end
  end

  def have_comment comment
    HaveComment.new comment
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
code-spec-0.4.0 lib/code_spec/matchers/have_comment.rb
code-spec-0.3.0 lib/code_spec/matchers/have_comment.rb
code-spec-0.2.11 lib/code_spec/matchers/have_comment.rb
code-spec-0.2.9 lib/code_spec/matchers/have_comment.rb