Sha256: 1dce343234fa9314ccf2412d4ce577493a561540263784bab8033e8e555e2733

Contents?: true

Size: 1.11 KB

Versions: 12

Compression:

Stored size: 1.11 KB

Contents

module TestServerFiles

  def add_file(path)
    full_path = temp_path(path)
    mkdir_p File.dirname(full_path)
    File.open(full_path, 'wb') do |file|
      file.write @templates[File.basename(full_path)]
    end
  end

  def set_mtime(path, mtime)
    full_path = temp_path(path)
    File.utime(File.atime(full_path), mtime, full_path)
  end

  def add_directory(path)
    full_path = temp_path(path)
    mkdir_p full_path
  end

  def has_file?(path)
    full_path = temp_path(path)
    File.exists?(full_path)
  end

  def has_file_with_contents_of?(path)
    expected_contents = @templates[File.basename(path)]
    all_paths.any? do |path|
      File.open(path, 'rb', &:read) == expected_contents
    end
  end

  def files_named_like(name)
    all_paths.select do |path|
      path.include?(name)
    end
  end

  def has_directory?(path)
    full_path = temp_path(path)
    File.directory?(full_path)
  end

  def file_contents(path)
    full_path = temp_path(path)
    File.open(full_path, 'rb', &:read)
  end

  def temp_path(path)
    File.expand_path(path, temp_dir)
  end

  def all_paths
    Dir[temp_path('**/*')]
  end

end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
ftpd-1.1.1 features/support/test_server_files.rb
ftpd-1.1.0 features/support/test_server_files.rb
investtools-ftpd-1.0.1 features/support/test_server_files.rb
ftpd-1.0.1 features/support/test_server_files.rb
ftpd-1.0.0 features/support/test_server_files.rb
ftpd-0.17.0 features/support/test_server_files.rb
ftpd-0.16.0 features/support/test_server_files.rb
ftpd-0.15.0 features/support/test_server_files.rb
ftpd-0.14.0 features/support/test_server_files.rb
ftpd-0.13.0 features/support/test_server_files.rb
ftpd-0.12.0 features/support/test_server_files.rb
ftpd-0.11.0 features/support/test_server_files.rb