Sha256: e7e0cb5bc968ab08351f3a153bfe9b6882fe4fd96628b561883a07c9b3b39272

Contents?: true

Size: 666 Bytes

Versions: 11

Compression:

Stored size: 666 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
      "Expected there to be the comment '# #{comment}'" 
    end 
    
    def negative_failure_message
      super
      "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

11 entries across 11 versions & 1 rubygems

Version Path
code-spec-0.2.8 lib/code_spec/matchers/have_comment.rb
code-spec-0.2.7 lib/code_spec/matchers/have_comment.rb
code-spec-0.2.6 lib/code_spec/matchers/have_comment.rb
code-spec-0.2.5 lib/code_spec/matchers/have_comment.rb
code-spec-0.2.4 lib/code_spec/matchers/have_comment.rb
code-spec-0.2.3 lib/code_spec/matchers/have_comment.rb
code-spec-0.2.2 lib/code_spec/matchers/have_comment.rb
code-spec-0.2.1 lib/code_spec/matchers/have_comment.rb
code-spec-0.2.0 lib/code_spec/matchers/have_comment.rb
code-spec-0.1.3 lib/code_spec/matchers/have_comment.rb
code-spec-0.1.2 lib/code_spec/matchers/have_comment.rb