Sha256: a300abcca0e6f9e1be7102e668f481390fc6263bc8c2728731cf0a4a341e5d17

Contents?: true

Size: 979 Bytes

Versions: 2

Compression:

Stored size: 979 Bytes

Contents

module AktionTest
  module Matchers
    module FileSystem
      module FileExistance
        def be_a_file
          Matcher.new
        end

        class Matcher < Matchers::Base
          def initialize
            super
          end

        protected
          
          def perform_match!
            file_exists? and file_is_not_a_directory?
          end

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

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

          def problems_for_should_not
          end

          def file_exists?
            File.exists? @subject
          end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aktion_test-0.3.1 lib/aktion_test/matchers/file_system/file_existance.rb
aktion_test-0.3.0 lib/aktion_test/matchers/file_system/file_existance.rb