Sha256: cb39445128a3b7e15db0b2a3f8e944d7440ae607249925cf477a3e7dfc17fae0

Contents?: true

Size: 996 Bytes

Versions: 17

Compression:

Stored size: 996 Bytes

Contents

module IMWTest
  module CustomMatchers

    # Check to see whether the given directory (a String) contains the
    # given +paths+
    #
    # @param [Array<String>] paths
    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.gsub(/\/+$/,'')) }
      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
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
imw-0.2.18 spec/support/custom_matchers.rb
imw-0.2.17 spec/support/custom_matchers.rb
imw-0.2.16 spec/support/custom_matchers.rb
imw-0.2.15 spec/support/custom_matchers.rb
imw-0.2.14 spec/support/custom_matchers.rb
imw-0.2.13 spec/support/custom_matchers.rb
imw-0.2.12 spec/support/custom_matchers.rb
imw-0.2.11 spec/support/custom_matchers.rb
imw-0.2.10 spec/support/custom_matchers.rb
imw-0.2.9 spec/support/custom_matchers.rb
imw-0.2.8 spec/support/custom_matchers.rb
imw-0.2.7 spec/support/custom_matchers.rb
imw-0.2.6 spec/support/custom_matchers.rb
imw-0.2.5 spec/support/custom_matchers.rb
imw-0.2.4 spec/support/custom_matchers.rb
imw-0.2.3 spec/support/custom_matchers.rb
imw-0.2.2 spec/support/custom_matchers.rb