Sha256: b27c6b55f01a1e0d9533f5cf90ae9655de96cb47d08b7d6a09345a2ef8f6364c

Contents?: true

Size: 890 Bytes

Versions: 2

Compression:

Stored size: 890 Bytes

Contents

module AktionTest
  module Matchers
    module FileSystem
      def be_a_file
        FileExistanceMatcher.new
      end

      class FileExistanceMatcher < Matchers::Base
        def initialize
        end

        def matches?(subject)
          @subject = subject
          file_exists? and file_is_not_a_directory?
        end

      protected

        def expectation
          "#{@subject} to be a file."
        end

        def problem
          if File.exists?(@subject)
            if File.directory?(@subject)
              "#{@subject} is a directory."
            else
              "Unknown"
            end
          else
            "#{@subject} does not exist."
          end
        end

        def file_exists?
          File.exists? @subject
        end

        def file_is_not_a_directory?
          !File.directory? @subject
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aktion_test-0.1.2 lib/aktion_test/matchers/file_system/be_a_file.rb
aktion_test-0.1.1 lib/aktion_test/matchers/file_system/be_a_file.rb