Sha256: 334d90d4d95b5ac7d3e6c5ca84ebc8251aa9c48ef320813c49f616c07600b956

Contents?: true

Size: 417 Bytes

Versions: 11

Compression:

Stored size: 417 Bytes

Contents

RSpec::Matchers.define :be_a_file do
  match do |path|
    @path = path.to_s
    file? && content_matches?
  end
  
  def with_content(content)
    @content = content
    self
  end

  def file?
    File.file?(@path)
  end

  def content_matches?
    case @content
    when String
      File.read(@path).strip == @content.strip
    when Regexp
      File.read(@path) =~ @content
    else
      true
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
massimo-0.10.3 spec/support/matchers/be_a_file_matcher.rb
massimo-0.10.2 spec/support/matchers/be_a_file_matcher.rb
massimo-0.10.1 spec/support/matchers/be_a_file_matcher.rb
massimo-0.10.0 spec/support/matchers/be_a_file_matcher.rb
massimo-0.9.0 spec/support/matchers/be_a_file_matcher.rb
massimo-0.8.5 spec/support/matchers/be_a_file_matcher.rb
massimo-0.8.4 spec/support/matchers/be_a_file_matcher.rb
massimo-0.8.3 spec/support/matchers/be_a_file_matcher.rb
massimo-0.8.2 spec/support/matchers/be_a_file_matcher.rb
massimo-0.8.1 spec/support/matchers/be_a_file_matcher.rb
massimo-0.8.0 spec/support/matchers/be_a_file_matcher.rb