Sha256: 44c329083caf3153749d0627285ffb5332b0ac70e559be8826f5ae1d567cdb13

Contents?: true

Size: 1.47 KB

Versions: 13

Compression:

Stored size: 1.47 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|
  matcher = if neg
              :should_not
            else
              :should
            end
  @list.filenames.send(matcher, include(filename))
end

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

Then /^the file list should be empty$/ do
  @list.should be_empty
end

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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
ftpd-0.17.0 features/step_definitions/list.rb
ftpd-0.16.0 features/step_definitions/list.rb
ftpd-0.15.0 features/step_definitions/list.rb
ftpd-0.14.0 features/step_definitions/list.rb
ftpd-0.13.0 features/step_definitions/list.rb
ftpd-0.12.0 features/step_definitions/list.rb
ftpd-0.11.0 features/step_definitions/list.rb
ftpd-0.10.0 features/step_definitions/list.rb
ftpd-0.9.0 features/step_definitions/list.rb
ftpd-0.7.1 features/step_definitions/list.rb
ftpd-0.8.0 features/step_definitions/list.rb
ftpd-0.7.0 features/step_definitions/list.rb
ftpd-0.6.0 features/step_definitions/list.rb