Sha256: 64ce6c4811559aa80f97b52ea866c822b67fa8e22ecc14b65cb0bdcdc38db895

Contents?: true

Size: 1017 Bytes

Versions: 11

Compression:

Stored size: 1017 Bytes

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 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

11 entries across 11 versions & 1 rubygems

Version Path
ftpd-0.10.0 features/support/test_server_files.rb
ftpd-0.9.0 features/support/test_server_files.rb
ftpd-0.7.1 features/support/test_server_files.rb
ftpd-0.8.0 features/support/test_server_files.rb
ftpd-0.7.0 features/support/test_server_files.rb
ftpd-0.6.0 features/support/test_server_files.rb
ftpd-0.5.0 features/support/test_server_files.rb
ftpd-0.4.0 features/support/test_server_files.rb
ftpd-0.3.2 features/support/test_server_files.rb
ftpd-0.3.1 features/support/test_server_files.rb
ftpd-0.2.2 features/support/test_server_files.rb