Sha256: 82a4d9c4656eece6bab6ccec71fe31e2f31b9838e24d0731b78c05d4b541023f

Contents?: true

Size: 788 Bytes

Versions: 4

Compression:

Stored size: 788 Bytes

Contents

module CustomMatchers
  def contain *paths
    paths = paths.flatten
    simple_matcher("contain #{paths.inspect}") do |given, matcher|
      given_contents = Dir[given + "/**/*"].map do |abs_path|
        abs_path[(given.length + 1)..-1]
      end
      matcher.failure_message = "expected #{given} to contain #{paths.inspect}, instead it contained #{given_contents.inspect}"
      matcher.negative_failure_message = "expected #{given} not to contain #{paths.inspect}"
      paths.all? { |path| given_contents.include?(path) }
    end
  end

  def exist
    simple_matcher("exist") do |given, matcher|
      matcher.failure_message = "expected #{given} to exist on disk"
      matcher.failure_message = "expected #{given} not to exist on disk"
      File.exist?(given)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
imw-0.2.1 spec/support/custom_matchers.rb
imw-0.2.0 spec/support/custom_matchers.rb
imw-0.1.1 spec/support/custom_matchers.rb
imw-0.1.0 spec/support/custom_matchers.rb