[DRE-commits] [ruby-aruba] 66/74: Split up feature

Hideki Yamane henrich at moszumanska.debian.org
Sat Nov 28 01:16:46 UTC 2015


This is an automated email from the git hooks/post-receive script.

henrich pushed a commit to branch debian/sid
in repository ruby-aruba.

commit ffd9d7fe2417c73bdf213aff0b4b74feb0fcd311
Author: Dennis Günnewig <dg1 at ratiodata.de>
Date:   Fri Nov 27 11:07:49 2015 +0100

    Split up feature
---
 features/file_system_commands.feature              | 220 ---------------------
 features/getting_started/cleanup.feature           |  15 ++
 features/steps/filesystem/append_to_file.feature   |  45 +++++
 features/steps/filesystem/cd_to_directory.feature  |  33 ++++
 .../steps/filesystem/check_file_content.feature    |  61 ++++++
 .../filesystem/check_permissions_of_file.feature   |  39 ++++
 features/steps/filesystem/compare_files.feature    |  42 ++++
 features/steps/filesystem/create_directory.feature |  20 +-
 features/steps/filesystem/create_file.feature      |  29 ++-
 .../filesystem/existence_of_directory.feature      |  57 ++++++
 .../steps/filesystem/existence_of_file.feature     |  43 ++++
 features/steps/filesystem/fixture.feature          |  20 ++
 .../filesystem/non_existence_of_directory.feature  |  69 +++++++
 .../steps/filesystem/non_existence_of_file.feature |  80 ++++++++
 features/steps/filesystem/remove_directory.feature |  38 ++++
 features/steps/filesystem/remove_file.feature      |  38 ++++
 fixtures/fixtures-app/test.txt                     |   1 -
 lib/aruba/cucumber/file.rb                         |  33 ++--
 18 files changed, 639 insertions(+), 244 deletions(-)

diff --git a/features/file_system_commands.feature b/features/file_system_commands.feature
deleted file mode 100644
index d913e7a..0000000
--- a/features/file_system_commands.feature
+++ /dev/null
@@ -1,220 +0,0 @@
-Feature: file system commands
-
-  In order to specify commands that load files
-  As a developer using Cucumber
-  I want to create temporary files
-
-  # Scenario: create a dir
-  #   Given a directory named "foo/bar"
-  #   When I run `file foo/bar`
-  #   Then the stdout should contain "foo/bar: directory"
-
-  # Scenario: create a file
-  #   Given a file named "foo/bar/example.txt" with:
-  #     """
-  #     hello world
-  #     """
-  #   When I run `cat foo/bar/example.txt`
-  #   Then the output should contain exactly "hello world"
-
-  Scenario: a file does not exist
-    Given a file named "example.txt" does not exist
-    Then the file "example.txt" should not exist
-
-  Scenario: a directory does not exist
-    Given a directory named "example.d" does not exist
-    Then the directory "foo" should not exist
-
-  Scenario: create a fixed sized file
-    Given a 1048576 byte file named "test.txt"
-    Then a 1048576 byte file named "test.txt" should exist
-
-  Scenario: Append to a file
-    \### We like appending to files:
-    1. Disk space is cheap
-    1. It's completely safe
-
-    \### Here is a list:
-    - One
-    - Two
-
-    Given a file named "foo/bar/example.txt" with:
-      """
-      hello world
-
-      """
-    When I append to "foo/bar/example.txt" with:
-      """
-      this was appended
-
-      """
-    When I run `cat foo/bar/example.txt`
-    Then the stdout should contain "hello world"
-    And the stdout should contain "this was appended"
-
-  Scenario: Append to a new file
-    When I append to "thedir/thefile" with "x"
-    And I append to "thedir/thefile" with "y"
-    Then the file "thedir/thefile" should contain "xy"
-
-  Scenario: clean up files generated in previous scenario
-    Then the file "foo/bar/example.txt" should not exist
-
-  Scenario: change to a subdir
-    Given a file named "foo/bar/example.txt" with:
-      """
-      hello world
-
-      """
-    When I cd to "foo/bar"
-    And I run `cat example.txt`
-    Then the output should contain "hello world"
-
-  Scenario: Reset current directory from previous scenario
-    When I run `pwd`
-    Then the output should match /\057tmp\057aruba$/
-
-  Scenario: Holler if cd to bad dir
-    When I do aruba I cd to "foo/nonexistant"
-    Then aruba should fail with "tmp/aruba/foo/nonexistant is not a directory"
-
-  Scenario: Check for presence of a subset of files
-    Given an empty file named "lorem/ipsum/dolor"
-    Given an empty file named "lorem/ipsum/sit"
-    Given an empty file named "lorem/ipsum/amet"
-    Then the following files should exist:
-      | lorem/ipsum/dolor |
-      | lorem/ipsum/amet  |
-
-  Scenario: Check for absence of files
-    Then the following files should not exist:
-      | lorem/ipsum/dolor |
-
-  Scenario: Check for presence of a single file
-    Given an empty file named "lorem/ipsum/dolor"
-    Then a file named "lorem/ipsum/dolor" should exist
-
-  Scenario: Check for absence of a single file
-    Then a file named "lorem/ipsum/dolor" should not exist
-
-  Scenario: Check for absence of a single file using a regex
-    Then a file matching %r<^ipsum> should not exist
-
-  Scenario: Check for presence of a single file using a regex
-    Given an empty file named "lorem/ipsum/dolor"
-    Then a file matching %r<dolor$> should exist
-
-  Scenario: Check for presence of a single file using a more complicated regex
-    Given an empty file named "lorem/ipsum/dolor"
-    Then a file matching %r<ipsum/dolor> should exist
-
-  Scenario: Check for presence of a subset of directories
-    Given a directory named "foo/bar"
-    Given a directory named "foo/bla"
-    Then the following directories should exist:
-      | foo/bar |
-      | foo/bla |
-
-  Scenario: check for absence of directories
-    Given a directory named "foo/bar"
-    Given a directory named "foo/bla"
-    Then the following step should fail with Spec::Expectations::ExpectationNotMetError:
-    """
-    Then the following directories should not exist:
-      | foo/bar/ |
-      | foo/bla/ |
-    """
-
-  Scenario: Check for presence of a single directory
-    Given a directory named "foo/bar"
-    Then a directory named "foo/bar" should exist
-
-  Scenario: Check for absence of a single directory
-    Given a directory named "foo/bar"
-    Then the following step should fail with Spec::Expectations::ExpectationNotMetError:
-      """
-      Then the directory "foo/bar" should not exist
-      """
-
-  Scenario: Check file contents with text
-    Given a file named "foo" with:
-      """
-      hello world
-      """
-    Then the file "foo" should contain "hello world"
-    And the file "foo" should not contain "HELLO WORLD"
-
-  Scenario: Check file contents with regexp
-    Given a file named "foo" with:
-      """
-      hello world
-      """
-    Then the file "foo" should match /hel.o world/
-    And the file "foo" should not match /HELLO WORLD/
-
-  Scenario: Check file contents with docstring
-    Given a file named "foo" with:
-      """
-      foo
-      bar
-      baz
-      foobar
-      """
-    Then the file "foo" should contain:
-      """
-      bar
-      baz
-      """
-
-  Scenario: Check file contents with another file
-    Given a file named "foo" with:
-      """
-      hello world
-      """
-    And a file named "bar" with:
-      """
-      hello world
-      """
-    And a file named "nonbar" with:
-      """
-      hello another world
-      """
-    Then the file "foo" should be equal to file "bar"
-    And the file "foo" should not be equal to file "nonbar"
-
-  Scenario: Remove file
-    Given a file named "foo" with:
-      """
-      hello world
-      """
-    When I remove the file "foo"
-    Then the file "foo" should not exist
-
-  Scenario: Remove directory
-    Given a directory named "foo"
-    When I remove the directory "foo"
-    Then the directory "foo" should not exist
-
-  Scenario: Just a dummy for reporting
-    Given an empty file named "a/b.txt"
-    Given an empty file named "a/b/c.txt"
-    Given an empty file named "a/b/c/d.txt"
-
-  Scenario: Change mode of empty file
-    Given an empty file named "test.txt" with mode "0666"
-    Then the mode of filesystem object "test.txt" should match "0666"
-
-  Scenario: Change mode of a directory
-    Given a directory named "test.d" with mode "0666"
-    Then the mode of filesystem object "test.d" should match "0666"
-
-  Scenario: Change mode of file
-    Given a file named "test.txt" with mode "0666" and with:
-    """
-    asdf
-    """
-    Then the mode of filesystem object "test.txt" should match "0666"
-
-  Scenario: Use a fixture
-    Given I use a fixture named "fixtures-app"
-    Then a file named "test.txt" should exist
diff --git a/features/getting_started/cleanup.feature b/features/getting_started/cleanup.feature
index 0427fac..1435f7b 100644
--- a/features/getting_started/cleanup.feature
+++ b/features/getting_started/cleanup.feature
@@ -50,3 +50,18 @@ Feature: Cleanup Aruba Working Directory
     """
     When I run `cucumber`
     Then the features should all pass
+
+  Scenario:  Current directory from previous scenario is reseted
+    Given a file named "features/non-existence.feature" with:
+    """
+    Feature: Reset
+      Scenario: Reset #1
+        Given a directory named "dir1"
+        When I cd to "dir1"
+
+      Scenario: Reset #2
+        When I run `pwd`
+        Then the output should match %r</tmp/aruba$>
+    """
+    When I run `cucumber`
+    Then the features should all pass
diff --git a/features/steps/filesystem/append_to_file.feature b/features/steps/filesystem/append_to_file.feature
new file mode 100644
index 0000000..65d9b86
--- /dev/null
+++ b/features/steps/filesystem/append_to_file.feature
@@ -0,0 +1,45 @@
+Feature: Append content to file
+
+  You might want to append some content to a file.
+
+  Background:
+    Given I use a fixture named "cli-app"
+
+  Scenario: Append to a existing file
+    Given a file named "features/non-existence.feature" with:
+    """
+    Feature: Existence
+      Scenario: Existence
+        Given a file named "foo/bar/example.txt" with:
+        \"\"\"
+        hello world
+        \"\"\"
+        When I append to "foo/bar/example.txt" with:
+        \"\"\"
+        this was appended
+        \"\"\"
+        Then the file named "foo/bar/example.txt" should contain:
+        \"\"\"
+        hello worldthis was appended
+        \"\"\"
+    """
+    When I run `cucumber`
+    Then the features should all pass
+
+  Scenario: Append to a non-existing file
+    Given a file named "features/non-existence.feature" with:
+    """
+    Feature: Existence
+      Scenario: Existence
+        Given a file named "foo/bar/example.txt" does not exist
+        When I append to "foo/bar/example.txt" with:
+        \"\"\"
+        this was appended
+        \"\"\"
+        Then the file named "foo/bar/example.txt" should contain:
+        \"\"\"
+        this was appended
+        \"\"\"
+    """
+    When I run `cucumber`
+    Then the features should all pass
diff --git a/features/steps/filesystem/cd_to_directory.feature b/features/steps/filesystem/cd_to_directory.feature
new file mode 100644
index 0000000..cc2f14c
--- /dev/null
+++ b/features/steps/filesystem/cd_to_directory.feature
@@ -0,0 +1,33 @@
+Feature: Change working directory
+
+  You might want to change the current working directory.
+
+  Background:
+    Given I use a fixture named "cli-app"
+
+  Scenario: Change to an existing sub directory
+    Given a file named "features/non-existence.feature" with:
+    """
+    Feature: Working Directory
+      Scenario: Working Directory
+        Given a file named "foo/bar/example.txt" with:
+        \"\"\"
+        hello world
+        \"\"\"
+        When I cd to "foo/bar"
+        And I run `cat example.txt`
+        Then the output should contain "hello world"
+        And the file "example.txt" should exist
+    """
+    When I run `cucumber`
+    Then the features should all pass
+
+  Scenario: Change to an non-existing sub directory
+    Given a file named "features/non-existence.feature" with:
+    """
+    Feature: Working Directory
+      Scenario: Working Directory
+        When I cd to "foo/bar/non-existing"
+    """
+    When I run `cucumber`
+    Then the features should not pass
diff --git a/features/steps/filesystem/check_file_content.feature b/features/steps/filesystem/check_file_content.feature
new file mode 100644
index 0000000..10be136
--- /dev/null
+++ b/features/steps/filesystem/check_file_content.feature
@@ -0,0 +1,61 @@
+Feature: Check file content
+
+  Background:
+    Given I use a fixture named "cli-app"
+
+  Scenario: Check file contents with plain text
+    Given a file named "features/non-existence.feature" with:
+    """
+    Feature: Check
+      Scenario: Check
+        Given a file named "foo" with:
+        \"\"\"
+        hello world
+        \"\"\"
+        Then the file "foo" should contain "hello world"
+        And the file "foo" should not contain "HELLO WORLD"
+    """
+    When I run `cucumber`
+    Then the features should all pass
+
+  Scenario: Check file contents with regular expression
+    Given a file named "features/non-existence.feature" with:
+    """
+    Feature: Check
+      Background:
+        Given a file named "foo" with:
+        \"\"\"
+        hello world
+        \"\"\"
+
+      Scenario: Check #1
+        Then the file "foo" should match /hel.o world/
+        And the file "foo" should not match /HELLO WORLD/
+
+      Scenario: Check #2
+        Then the file "foo" should match %r<hel.o world>
+        And the file "foo" should not match %r<HELLO WORLD>
+    """
+    When I run `cucumber`
+    Then the features should all pass
+
+  Scenario:  Check file contents with cucumber doc string
+    Given a file named "features/non-existence.feature" with:
+    """
+    Feature: Existence
+      Scenario: Existence
+        Given a file named "foo" with:
+        \"\"\"
+        foo
+        bar
+        baz
+        foobar
+        \"\"\"
+        Then the file "foo" should contain:
+        \"\"\"
+        bar
+        baz
+        \"\"\"
+        """
+    When I run `cucumber`
+    Then the features should all pass
diff --git a/features/steps/filesystem/check_permissions_of_file.feature b/features/steps/filesystem/check_permissions_of_file.feature
new file mode 100644
index 0000000..ee665f0
--- /dev/null
+++ b/features/steps/filesystem/check_permissions_of_file.feature
@@ -0,0 +1,39 @@
+Feature: Check permissions of file
+
+  Background:
+    Given I use a fixture named "cli-app"
+
+  Scenario: Check mode of existing file
+    Given a file named "features/create_file.feature" with:
+    """
+    Feature: Check
+      Background:
+        Given an empty file named "file1.txt" with mode "0644"
+
+      Scenario: Check #1
+        Then the file named "file1.txt" should have permissions "0644"
+
+      Scenario: Check #2
+        Then a file "file1.txt" should have permissions "0644"
+
+      Scenario: Check #3
+        Then a file "file1.txt" should not have permissions "0444"
+
+      Scenario: Check #4
+        Then the file "file1.txt" should not have permissions "0444"
+    """
+    When I run `cucumber`
+    Then the features should all pass
+
+  Scenario: Check mode of non-existing file
+    Given a file named "features/create_file.feature" with:
+    """
+    Feature: Check
+      Background:
+        Given a file named "file1.txt" does not exist
+
+      Scenario: Check 
+        Then the file named "file1.txt" should have permissions "0644"
+    """
+    When I run `cucumber`
+    Then the features should not pass
diff --git a/features/steps/filesystem/compare_files.feature b/features/steps/filesystem/compare_files.feature
new file mode 100644
index 0000000..0660e35
--- /dev/null
+++ b/features/steps/filesystem/compare_files.feature
@@ -0,0 +1,42 @@
+Feature: Compare files
+
+  Background:
+    Given I use a fixture named "cli-app"
+
+  Scenario: Compare existing files
+    Given a file named "features/non-existence.feature" with:
+    """
+    Feature: Existence
+      Scenario: Existence
+        Given a file named "foo" with:
+        \"\"\"
+        hello world
+        \"\"\"
+        And a file named "bar" with:
+        \"\"\"
+        hello world
+        \"\"\"
+        And a file named "nonbar" with:
+        \"\"\"
+        hello another world
+        \"\"\"
+        Then the file "foo" should be equal to file "bar"
+        And the file "foo" should not be equal to file "nonbar"
+    """
+    When I run `cucumber`
+    Then the features should all pass
+
+  Scenario: Compare non-existing files
+    Given a file named "features/non-existence.feature" with:
+    """
+    Feature: Existence
+      Scenario: Existence
+        Given a file named "foo" with:
+        \"\"\"
+        hello world
+        \"\"\"
+        Then the file "foo" should be equal to file "bar"
+    """
+    When I run `cucumber`
+    Then the features should not pass
+
diff --git a/features/steps/filesystem/create_directory.feature b/features/steps/filesystem/create_directory.feature
index d6d92f4..c5b825d 100644
--- a/features/steps/filesystem/create_directory.feature
+++ b/features/steps/filesystem/create_directory.feature
@@ -10,13 +10,23 @@ Feature: Create Directory
     Given a file named "features/create_directory.feature" with:
     """
     Feature: Create directory
-      Scenario: Create directory
+      Background:
         Given a directory named "dir1"
-        Given the directory "dir2"
-        Given the directory named "dir3"
+
+      Scenario: Create directory #1
+        Then a directory named "dir1" should exist
+
+      Scenario: Create directory #2
+        Then a directory named "dir1" should exist
+
+      Scenario: Create directory #3
+        Then a directory named "dir1" should exist
+
+      Scenario: Create directory #4
+        Then a directory named "dir1" should exist
+
+      Scenario: Create directory #5
         Then a directory named "dir1" should exist
-        And a directory named "dir2" should exist
-        And a directory named "dir3" should exist
     """
     When I run `cucumber`
     Then the features should all pass
diff --git a/features/steps/filesystem/create_file.feature b/features/steps/filesystem/create_file.feature
index 1fb4b3f..a4a2ee1 100644
--- a/features/steps/filesystem/create_file.feature
+++ b/features/steps/filesystem/create_file.feature
@@ -34,11 +34,11 @@ Feature: Create new File
     When I run `cucumber`
     Then the features should all pass
 
-  Scenario: Change mode a long with creation of file
+  Scenario: Change mode a long with creation of a file with content
     Given a file named "features/create_file.feature" with:
     """
-    Feature: Create directory
-      Scenario: Create directory
+    Feature: Create file
+      Scenario: Create file
         Given a file named "file1.txt" with mode "0644" and with:
         \"\"\"
         Hello World
@@ -51,3 +51,26 @@ Feature: Create new File
     """
     When I run `cucumber`
     Then the features should all pass
+
+  Scenario: Change mode a long with creation of empty file
+    Given a file named "features/create_file.feature" with:
+    """
+    Feature: Create file
+      Scenario: Create file
+        Given an empty file named "file1.txt" with mode "0644"
+        Then the file named "file1.txt" should have permissions "0644"
+    """
+    When I run `cucumber`
+    Then the features should all pass
+
+  Scenario: Create a fixed sized file
+    Given a file named "features/non-existence.feature" with:
+    """
+    Feature: Create file
+      Scenario: Create file
+        Given a 1048576 byte file named "test.txt"
+        Then a 1048576 byte file named "test.txt" should exist
+    """
+    When I run `cucumber`
+    Then the features should all pass
+
diff --git a/features/steps/filesystem/existence_of_directory.feature b/features/steps/filesystem/existence_of_directory.feature
new file mode 100644
index 0000000..1afac00
--- /dev/null
+++ b/features/steps/filesystem/existence_of_directory.feature
@@ -0,0 +1,57 @@
+Feature: Make sure and check a directory exists
+
+  To setup a working environment, you may want to make sure, that a
+  directory exist.
+
+  Background:
+    Given I use a fixture named "cli-app"
+
+  Scenario: Check for presence of a single directory
+    Given a file named "features/existence.feature" with:
+    """
+    Feature: Existence
+      Background:
+        Given an empty directory "lorem/ipsum/dolor"
+
+      Scenario: Existence #1
+        Then the directory "lorem/ipsum/dolor" should exist
+
+      Scenario: Existence #2
+        Then the directory named "lorem/ipsum/dolor" should exist
+
+      Scenario: Existence #3
+        Then a directory named "lorem/ipsum/dolor" should exist
+    """
+    When I run `cucumber`
+    Then the features should all pass
+
+  Scenario: Check for presence of a multiple directories
+    Given a file named "features/existence.feature" with:
+    """
+    Feature: Existence
+      Scenario: Existence
+        Given an empty directory "lorem/ipsum/dolor"
+        And an empty directory "lorem/ipsum/amet"
+        Then the following directories should exist:
+          | lorem/ipsum/dolor |
+          | lorem/ipsum/amet  |
+    """
+    When I run `cucumber`
+    Then the features should all pass
+
+
+  Scenario: Check for presence of a subset of directories
+    Given a file named "features/existence.feature" with:
+    """
+    Feature: Existence
+      Scenario: Existence
+        Given an empty directory "lorem/ipsum/dolor"
+        And an empty directory "lorem/ipsum/amet"
+        And an empty directory "lorem/ipsum/sit"
+        Then the following directories should exist:
+          | lorem/ipsum/dolor |
+          | lorem/ipsum/amet  |
+    """
+    When I run `cucumber`
+    Then the features should all pass
+
diff --git a/features/steps/filesystem/existence_of_file.feature b/features/steps/filesystem/existence_of_file.feature
new file mode 100644
index 0000000..2064fee
--- /dev/null
+++ b/features/steps/filesystem/existence_of_file.feature
@@ -0,0 +1,43 @@
+Feature: Make sure and check a file exists
+
+  To setup a working environment, you may want to make sure, that a
+  file exist or if you ran your command of a file
+  was deleted.
+
+  Background:
+    Given I use a fixture named "cli-app"
+
+  Scenario: Check for presence of a single file
+    Given an empty file named "lorem/ipsum/dolor"
+    Then a file named "lorem/ipsum/dolor" should exist
+
+  Scenario: Check for presence of a subset of files
+    Given a file named "features/existence.feature" with:
+    """
+    Feature: Existence
+      Scenario: Existence
+        Given an empty file named "lorem/ipsum/dolor"
+        And an empty file named "lorem/ipsum/sit"
+        And an empty file named "lorem/ipsum/amet"
+        Then the following files should exist:
+          | lorem/ipsum/dolor |
+          | lorem/ipsum/amet  |
+    """
+    When I run `cucumber`
+    Then the features should all pass
+
+  Scenario: Check for presence of a single file using a regex
+    Given a file named "features/non-existence.feature" with:
+    """
+    Feature: Existence
+      Background:
+        Given an empty file named "lorem/ipsum/dolor"
+
+      Scenario: Existence #1
+        Then a file matching %r<dolor$> should exist
+
+      Scenario: Existence #2
+        Then a file matching %r<ipsum/dolor> should exist
+    """
+    When I run `cucumber`
+    Then the features should all pass
diff --git a/features/steps/filesystem/fixture.feature b/features/steps/filesystem/fixture.feature
new file mode 100644
index 0000000..f6cfa3c
--- /dev/null
+++ b/features/steps/filesystem/fixture.feature
@@ -0,0 +1,20 @@
+Feature: Use fixtures in your tests
+
+  If you have more complicated requirements at your test setup, you can use
+  fixtures with `aruba`.
+
+  Background:
+    Given I use a fixture named "cli-app"
+
+  Scenario: Use a fixture for your tests
+    Given a file named "features/fixtures.feature" with:
+    """
+    Feature: Fixture
+      Scenario: Fixture
+        Given I use a fixture named "fixtures-app"
+        Then a file named "test.txt" should exist
+    """
+    And a directory named "fixtures"
+    And an empty file named "fixtures/fixtures-app/test.txt"
+    When I run `cucumber`
+    Then the features should all pass
diff --git a/features/steps/filesystem/non_existence_of_directory.feature b/features/steps/filesystem/non_existence_of_directory.feature
new file mode 100644
index 0000000..7ab8a37
--- /dev/null
+++ b/features/steps/filesystem/non_existence_of_directory.feature
@@ -0,0 +1,69 @@
+Feature: Make sure and check a directory does not exist
+
+  To setup a working environment, you may want to make sure, that a
+  directory does not exist or if you ran your command of a directory
+  was deleted.
+
+  Background:
+    Given I use a fixture named "cli-app"
+
+  Scenario: Delete existing directory
+    Given a file named "features/non-existence.feature" with:
+    """
+    Feature: Non-Existence
+      Background:
+        Given a directory named "example.d" does not exist
+
+      Scenario: Non-Existence #1
+        Then the directory "example.d" should not exist
+
+      Scenario: Non-Existence #2
+        Then the directory "example.d" should not exist
+
+      Scenario: Non-Existence #3
+        Then the directory "example.d" should not exist
+    """
+    When I run `cucumber`
+    Then the features should all pass
+
+  Scenario: Check if a directory does not exists
+    Given a file named "features/non-existence.feature" with:
+    """
+    Feature: Non-Existence
+      Background:
+        Given a directory named "example.d" does not exist
+
+      Scenario: Non-Existence #1
+        Then the directory "example.d" should not exist
+
+      Scenario: Non-Existence #2
+        Then the directory named "example.d" should not exist
+
+      Scenario: Non-Existence #3
+        Then a directory named "example.d" should not exist
+
+      Scenario: Non-Existence #4
+        Then a directory named "example.d" should not exist anymore
+
+      Scenario: Non-Existence #5
+        Then the directory named "example.d" should not exist anymore
+
+      Scenario: Non-Existence #6
+        Then the directory "example.d" should not exist anymore
+    """
+    When I run `cucumber`
+    Then the features should all pass
+
+  Scenario: Check for absence of a subset of directories
+    Given a file named "features/non-existence.feature" with:
+    """
+    Feature: Non-Existence
+      Scenario: Non-Existence
+        Given the directory "lorem/ipsum/dolor" does not exist
+        And the directory "lorem/ipsum/amet" does not exist
+        Then the following directories should not exist:
+          | lorem/ipsum/dolor |
+          | lorem/ipsum/amet  |
+    """
+    When I run `cucumber`
+    Then the features should all pass
diff --git a/features/steps/filesystem/non_existence_of_file.feature b/features/steps/filesystem/non_existence_of_file.feature
new file mode 100644
index 0000000..973a7d4
--- /dev/null
+++ b/features/steps/filesystem/non_existence_of_file.feature
@@ -0,0 +1,80 @@
+Feature: Make sure and check a file does not exist
+
+  To setup a working environment, you may want to make sure, that a
+  file does not exist or if you ran your command of a file
+  was deleted.
+
+  Background:
+    Given I use a fixture named "cli-app"
+
+  Scenario: Delete existing file
+    Given a file named "features/non-existence.feature" with:
+    """
+    Feature: Non-Existence
+      Background:
+        Given a file named "example.txt" does not exist
+
+      Scenario: Non-Existence #1
+        Then the file "example.txt" should not exist
+
+      Scenario: Non-Existence #2
+        Then the file "example.txt" should not exist
+
+      Scenario: Non-Existence #3
+        Then the file "example.txt" should not exist
+    """
+    When I run `cucumber`
+    Then the features should all pass
+
+  Scenario: Check if a file does not exists
+    Given a file named "features/non-existence.feature" with:
+    """
+    Feature: Non-Existence
+      Background:
+        Given a file named "example.txt" does not exist
+
+      Scenario: Non-Existence #1
+        Then the file "example.txt" should not exist
+
+      Scenario: Non-Existence #2
+        Then the file named "example.txt" should not exist
+
+      Scenario: Non-Existence #3
+        Then a file named "example.txt" should not exist
+
+      Scenario: Non-Existence #4
+        Then a file named "example.txt" should not exist anymore
+
+      Scenario: Non-Existence #5
+        Then the file named "example.txt" should not exist anymore
+
+      Scenario: Non-Existence #6
+        Then the file "example.txt" should not exist anymore
+    """
+    When I run `cucumber`
+    Then the features should all pass
+
+  Scenario: Check for absence of multiple files
+    Given a file named "features/non-existence.feature" with:
+    """
+    Feature: Non-Existence
+      Scenario: Non-Existence
+        Given the file "lorem/ipsum/dolor.txt" does not exist
+        Given the file "lorem/ipsum/sit.txt" does not exist
+        Then the following files should not exist:
+          | lorem/ipsum/dolor.txt |
+          | lorem/ipsum/sit.txt |
+    """
+    When I run `cucumber`
+    Then the features should all pass
+
+  Scenario: Check for absence of a single file using a regex
+    Given a file named "features/non-existence.feature" with:
+    """
+    Feature: Existence
+      Scenario: Existence
+        Given the file "lorem/ipsum/sit.txt" does not exist
+        Then a file matching %r<^ipsum> should not exist
+    """
+    When I run `cucumber`
+    Then the features should all pass
diff --git a/features/steps/filesystem/remove_directory.feature b/features/steps/filesystem/remove_directory.feature
new file mode 100644
index 0000000..f241fab
--- /dev/null
+++ b/features/steps/filesystem/remove_directory.feature
@@ -0,0 +1,38 @@
+Feature: Remove a directory
+
+  Background:
+    Given I use a fixture named "cli-app"
+
+  Scenario: Remove an existing directory
+    Given a file named "features/non-existence.feature" with:
+    """
+    Feature: Remove
+      Scenario: Remove
+        Given an empty directory named "foo"
+        When I remove the directory "foo"
+        Then the directory "foo" should not exist
+    """
+    When I run `cucumber`
+    Then the features should all pass
+
+  Scenario: Remove an non-existing directory
+    Given a file named "features/non-existence.feature" with:
+    """
+    Feature: Remove
+      Scenario: Remove
+        When I remove the directory "foo"
+        Then the directory "foo" should not exist
+    """
+    When I run `cucumber`
+    Then the features should not pass
+
+  Scenario: Force remove an non-existing directory
+    Given a file named "features/non-existence.feature" with:
+    """
+    Feature: Remove
+      Scenario: Remove
+        When I remove the directory "foo" with full force
+        Then the directory "foo" should not exist
+    """
+    When I run `cucumber`
+    Then the features should all pass
diff --git a/features/steps/filesystem/remove_file.feature b/features/steps/filesystem/remove_file.feature
new file mode 100644
index 0000000..ab117e7
--- /dev/null
+++ b/features/steps/filesystem/remove_file.feature
@@ -0,0 +1,38 @@
+Feature: Remove a file
+
+  Background:
+    Given I use a fixture named "cli-app"
+
+  Scenario: Remove an existing file
+    Given a file named "features/non-existence.feature" with:
+    """
+    Feature: Remove
+      Scenario: Remove
+        Given an empty file named "foo"
+        When I remove the file "foo"
+        Then the file "foo" should not exist
+    """
+    When I run `cucumber`
+    Then the features should all pass
+
+  Scenario: Remove an non-existing file
+    Given a file named "features/non-existence.feature" with:
+    """
+    Feature: Remove
+      Scenario: Remove
+        When I remove the file "foo"
+        Then the file "foo" should not exist
+    """
+    When I run `cucumber`
+    Then the features should not pass
+
+  Scenario: Force remove an non-existing file
+    Given a file named "features/non-existence.feature" with:
+    """
+    Feature: Remove
+      Scenario: Remove
+        When I remove the file "foo" with full force
+        Then the file "foo" should not exist
+    """
+    When I run `cucumber`
+    Then the features should all pass
diff --git a/fixtures/fixtures-app/test.txt b/fixtures/fixtures-app/test.txt
deleted file mode 100644
index 8bd6648..0000000
--- a/fixtures/fixtures-app/test.txt
+++ /dev/null
@@ -1 +0,0 @@
-asdf
diff --git a/lib/aruba/cucumber/file.rb b/lib/aruba/cucumber/file.rb
index 682c81e..76d4be6 100644
--- a/lib/aruba/cucumber/file.rb
+++ b/lib/aruba/cucumber/file.rb
@@ -11,7 +11,7 @@ Given(/^I move (?:a|the) (file|directory)(?: (?:named|from))? "([^"]*)" to "([^"
   move source, destination
 end
 
-Given(/^(?:a|the) directory(?: named)? "([^"]*)"$/) do |dir_name|
+Given(/^(?:a|the|(?:an empty)) directory(?: named)? "([^"]*)"$/) do |dir_name|
   create_directory(dir_name)
 end
 
@@ -66,8 +66,8 @@ When(/^I append to "([^"]*)" with "([^"]*)"$/) do |file_name, file_content|
   append_to_file(file_name, file_content)
 end
 
-When(/^I remove (?:a|the) (?:file|directory)(?: named)? "([^"]*)"$/) do |name|
-  remove(name)
+When(/^I remove (?:a|the) (?:file|directory)(?: named)? "([^"]*)"( with full force)?$/) do |name, force_remove|
+  remove(name, :force => force_remove.nil? ? false : true)
 end
 
 Given(/^(?:a|the) (?:file|directory)(?: named)? "([^"]*)" does not exist$/) do |name|
@@ -88,12 +88,23 @@ Then(/^the following files should (not )?exist:$/) do |negated, files|
   end
 end
 
-Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?exist(?: anymore)?$/) do |file, expect_match|
-  if expect_match
-    expect(file).not_to be_an_existing_file
+Then(/^(?:a|the) (file|directory)(?: named)? "([^"]*)" should (not )?exist(?: anymore)?$/) do |directory_or_file, path, expect_match|
+  if directory_or_file == 'file'
+    if expect_match
+      expect(path).not_to be_an_existing_file
+    else
+      expect(path).to be_an_existing_file
+    end
+  elsif directory_or_file == 'directory'
+    if expect_match
+      expect(path).not_to be_an_existing_directory
+    else
+      expect(path).to be_an_existing_directory
+    end
   else
-    expect(file).to be_an_existing_file
+    fail ArgumentError, %("#{directory_or_file}" can only be "directory" or "file".)
   end
+
 end
 
 Then(/^(?:a|the) file matching %r<(.*?)> should (not )?exist$/) do |pattern, expect_match|
@@ -122,14 +133,6 @@ Then(/^the following directories should (not )?exist:$/) do |negated, directorie
   end
 end
 
-Then(/^(?:a|the) directory(?: named)? "([^"]*)" should (not )?exist$/) do |directory, negated|
-  if negated
-    expect(directory).not_to be_an_existing_directory
-  else
-    expect(directory).to be_an_existing_directory
-  end
-end
-
 Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?contain "([^"]*)"$/) do |file, negated, content|
   if negated
     expect(file).not_to have_file_content file_content_including(content.chomp)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-aruba.git



More information about the Pkg-ruby-extras-commits mailing list