The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Test::BDD::Infrastructure::File - cucumber step definitions for checking files

VERSION

version 1.005

Synopsis

  Scenario: Check /etc/hosts file
    Given the file /etc/hosts exists
    Then the file must be non-zero size
    And the file type must be plain file
    And the file mode must be 0644
    And the file must be owned by user root
    And the file must be owned by group root
    And the file size must be at least 200 byte
    And the file mtime must be newer than 20 years
    And the file mtime must be older than 30 seconds
    And the file must contain at least 10 lines

  Scenario: test /etc directory
    Given the directory /etc exists
    Then the file type must be directory
    And the directory must contain at least 100 files

Step definitions

The path of the directory or file must be specified with:

  Given the file <path> exists

or

  Given the directory <path> exists

Basic file checks

  Then the file must be empty
  Then the file must be non-zero size
  Then the file must be non-zero size
  Then the file type must be plain file
  Then the file type must be directory
  Then the file type must be symbolic link
  Then the file type must be socket
  Then the file type must be pipe
  Then the file type must be block device
  Then the file type must be character device

File attribute checks

  Then the file mode must be <octal mode>
  Then the file must be owned by user <uid|username>
  Then the file must be owned by group <gid|groupname>
  Then the file size must be <compare operator> <count> <byte unit>
  Then the file atime must be <compare operator> <count> <interval>
  Then the file ctime must be <compare operator> <count> <interval>
  Then the file mtime must be <compare operator> <count> <interval>

Examples

  Then the file must be owned by user root
  Then the file mtime must be newer than 20 years
  Then the file size must be at least 200 bytes

File content checks

  Then the file must contain <compare> <count> lines
  Then the files content must match <regex>
  Then the files content must not match <regex>

Directory content checks

  Then the directory must contain <compare> <count> files
  Then the directory must contain a file like <regex>
  Then the directory must contain no file like <regex>

AUTHOR

Markus Benning <ich@markusbenning.de>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by Markus Benning.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.