Sha256: 72f84acaa8eefccbb15e17ffb64863bd39030bb874b0fa21bb90b6a7c33e3cd6

Contents?: true

Size: 675 Bytes

Versions: 2

Compression:

Stored size: 675 Bytes

Contents

module ProcFetch
  module StubDir
    # Stub Dir.foreach method for fake /proc directory
    #
    # @example
    # dir_foreach({:pid => '1761', :process_list => ['1768', '123']'})
    #
    # @return
    def dir_foreach(args)
      pid = args[:pid] || 1
      procs_list = args[:process_list]
      allow(Dir).to receive(:foreach) do |dir|
        if dir == '/proc'
          procs_list
        elsif dir == "/proc/#{pid}/fd"
          ['0','1','2','3']
        end
      end
    end


    # Stub Dir.exist? method
    #
    # @example
    # dir_exist()
    #
    # @return [Boolen]
    def dir_exists
      allow(Dir).to receive(:exist?).and_return(true)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hawatel_ps-0.1.2 spec/linux/support/stub_dir.rb
hawatel_ps-0.1.1 spec/linux/support/stub_dir.rb