Sha256: b5d135219e560e511f4e0987a15c139036a8280130dafdbf981b95b6d7d9e613

Contents?: true

Size: 1.46 KB

Versions: 5

Compression:

Stored size: 1.46 KB

Contents

class FileList

  def initialize(lines)
    @lines = lines
  end

  def filenames
    @lines.map(&:split).map(&:last)
  end

  def long_form?
    @lines.all? do |line|
      line =~ /^[rwxSst-]{10}/
    end
  end

  def short_form?
    !long_form?
  end

  def eplf_format?
    @lines.all? do |line|
      line =~ /^\+.*\t.*$/
    end
  end

  def empty?
    @lines.empty?
  end

end

When /^the client successfully lists the directory(?: "(.*?)")?$/ do |directory|
  @list = FileList.new(client.ls(*[directory].compact))
end

When /^the client lists the directory( "(?:.*?)")?$/ do |directory|
  capture_error do
    step "the client successfully lists the directory#{directory}"
  end
end

When /^the client successfully name-lists the directory(?: "(.*?)")?$/ do
|directory|
  @list = FileList.new(client.nlst(*[directory].compact))
end

When /^the client name-lists the directory( "(?:.*?)")?$/ do |directory|
  capture_error do
    step "the client successfully name-lists the directory#{directory}"
  end
end

Then /^the file list should( not)? contain "(.*?)"$/ do |neg, filename|
  verb = if neg
           :to_not
         else
           :to
         end
  expect(@list.filenames).send(verb, include(filename))
end

Then /^the file list should be in (long|short) form$/ do |form|
  expect(@list).to send("be_#{form}_form")
end

Then /^the file list should be empty$/ do
  expect(@list).to be_empty
end

Then /^the list should be in EPLF format$/ do
  expect(@list).to be_eplf_format
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
ftpd-1.1.1 features/step_definitions/list.rb
ftpd-1.1.0 features/step_definitions/list.rb
investtools-ftpd-1.0.1 features/step_definitions/list.rb
ftpd-1.0.1 features/step_definitions/list.rb
ftpd-1.0.0 features/step_definitions/list.rb