Sha256: 9690a25d3a3a16a24f3b13cd0e1d06f3657dc5b1fac15aa0d4dd67b13b6422ed

Contents?: true

Size: 1.07 KB

Versions: 20

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

module MutantSpec
  class FileState
    DEFAULTS = IceNine.deep_freeze(
      file:     false,
      contents: nil,
      requires: []
    )

    include Adamantium, Anima.new(*DEFAULTS.keys)

    def self.new(attributes = DEFAULTS)
      super(DEFAULTS.merge(attributes))
    end

    DOES_NOT_EXIST = new

    alias_method :file?, :file
  end # FileState

  class FakePathname
    include Adamantium, Concord.new(:file_system, :pathname)

    def join(*arguments)
      self.class.new(
        file_system,
        pathname.join(*arguments)
      )
    end

    def read
      state.contents
    end

    def to_s
      pathname.to_s
    end

    def file?
      state.file?
    end

  private

    def state
      file_system.state(pathname.to_s)
    end
  end # FakePathname

  class FileSystem
    include Adamantium, Concord.new(:file_states)

    def state(filename)
      file_states.fetch(filename, FileState::DOES_NOT_EXIST)
    end

    def path(filename)
      FakePathname.new(self, Pathname.new(filename))
    end
  end # FileSystem
end # MutantSpec

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
mutant-0.9.11 spec/support/file_system.rb
mutant-0.9.10 spec/support/file_system.rb
mutant-0.9.9 spec/support/file_system.rb
mutant-0.9.8 spec/support/file_system.rb
mutant-0.9.7 spec/support/file_system.rb
mutant-0.9.6 spec/support/file_system.rb
mutant-0.9.5 spec/support/file_system.rb
mutant-0.9.4 spec/support/file_system.rb
mutant-0.9.3 spec/support/file_system.rb
mutant-0.9.2 spec/support/file_system.rb
mutant-0.9.1 spec/support/file_system.rb
mutant-0.9.0 spec/support/file_system.rb
mutant-0.8.24 spec/support/file_system.rb
mutant-0.8.23 spec/support/file_system.rb
mutant-0.8.22 spec/support/file_system.rb
mutant-0.8.21 spec/support/file_system.rb
mutant-0.8.20 spec/support/file_system.rb
mutant-0.8.19 spec/support/file_system.rb
mutant-0.8.18 spec/support/file_system.rb
mutant-0.8.17 spec/support/file_system.rb