diff --git a/features/core.feature b/features/core.feature index ab86da42..477d1bac 100644 --- a/features/core.feature +++ b/features/core.feature @@ -58,3 +58,16 @@ Feature: Basic reading and writing to a journal When we run "jrnl -on 2013-06-10 -s" Then the output should be "2013-06-10 15:40 Life is good." + # The input for this test is y + Scenario: --delete flag allows deletion of single entry + Given we use the config "deletion.yaml" + When we run "jrnl --delete" + And we type " " + And we type + """ + + y + """ + When we run "jrnl -on 2019-10-29 -s" + Then the output should not contain "2019-10-29 11:11 First entry." + diff --git a/features/data/configs/deletion.yaml b/features/data/configs/deletion.yaml new file mode 100644 index 00000000..d4155260 --- /dev/null +++ b/features/data/configs/deletion.yaml @@ -0,0 +1,12 @@ +default_hour: 9 +default_minute: 0 +editor: "" +encrypt: false +highlight: true +journals: + default: features/journals/deletion.journal +linewrap: 80 +tagsymbols: "@" +template: false +timeformat: "%Y-%m-%d %H:%M" +indent_character: "|" diff --git a/features/data/journals/deletion.journal b/features/data/journals/deletion.journal new file mode 100644 index 00000000..c0fa689d --- /dev/null +++ b/features/data/journals/deletion.journal @@ -0,0 +1,5 @@ +[2019-10-29 11:11] First entry. + +[2019-10-29 11:11] Second entry. + +[2019-10-29 11:13] Third entry. \ No newline at end of file diff --git a/features/environment.py b/features/environment.py index 6f9ac5df..d7eeef55 100644 --- a/features/environment.py +++ b/features/environment.py @@ -7,6 +7,7 @@ try: except ImportError: from cStringIO import StringIO + def before_scenario(context, scenario): """Before each scenario, backup all config and journal test data.""" context.messages = StringIO() @@ -19,7 +20,6 @@ def before_scenario(context, scenario): if os.path.exists(working_dir): shutil.rmtree(working_dir) - for folder in ("configs", "journals"): original = os.path.join("features", "data", folder) working_dir = os.path.join("features", folder) @@ -32,6 +32,7 @@ def before_scenario(context, scenario): else: shutil.copy2(source, working_dir) + def after_scenario(context, scenario): """After each scenario, restore all test data and remove working_dirs.""" context.messages.close()