From 3d29b6b6a1cf6e35278339d0ef8f39667208da5f Mon Sep 17 00:00:00 2001 From: Micah Jerome Ellison Date: Sat, 24 Apr 2021 15:18:11 -0700 Subject: [PATCH] Fix star and tag feature language and add output should be empty test Co-authored-by: Jonathan Wren --- tests/features/star.feature | 20 ++++++++--------- tests/features/tag.feature | 45 +++++++++++++++++-------------------- tests/step_defs/conftest.py | 15 +++++++------ 3 files changed, 38 insertions(+), 42 deletions(-) diff --git a/tests/features/star.feature b/tests/features/star.feature index f0188056..7b1b42f1 100644 --- a/tests/features/star.feature +++ b/tests/features/star.feature @@ -1,20 +1,20 @@ Feature: Starring entries Scenario Outline: Starring an entry will mark it in the journal file - Given we use the config ".yaml" + Given we use the config "" When we run "jrnl 20 july 2013 *: Best day of my life!" Then we should see the message "Entry added" When we run "jrnl -on 2013-07-20 -starred" Then the output should contain "2013-07-20 09:00 Best day of my life!" Examples: configs - | config_file | - | simple | - | empty_folder | - | dayone | + | config_file | + | simple.yaml | + | empty_folder.yaml | + | dayone.yaml | Scenario Outline: Filtering by starred entries will show only starred entries - Given we use the config ".yaml" + Given we use the config "" When we run "jrnl -starred" Then the output should be empty When we run "jrnl 20 july 2013 *: Best day of my life!" @@ -22,10 +22,10 @@ Feature: Starring entries Then the output should be "2013-07-20 09:00 Best day of my life!" Examples: configs - | config_file | - | simple | - | empty_folder | - | dayone_empty | + | config_file | + | simple.yaml | + | empty_folder.yaml | + | dayone_empty.yaml | Scenario: Starring an entry will mark it in an encrypted journal Given we use the config "encrypted.yaml" diff --git a/tests/features/tag.feature b/tests/features/tag.feature index b7b687b5..a62b5ac8 100644 --- a/tests/features/tag.feature +++ b/tests/features/tag.feature @@ -3,51 +3,46 @@ Feature: Tagging # And format.feature for tag-related output Scenario Outline: Tags should allow certain special characters such as /, +, # - Given we use the config ".yaml" + Given we use the config "" When we run "jrnl 2020-09-26: This is an entry about @os/2 and @c++ and @c#" When we run "jrnl --tags -on 2020-09-26" Then we should get no error And the output should be - """ - @os/2 : 1 - @c++ : 1 - @c# : 1 - """ + @os/2 : 1 + @c++ : 1 + @c# : 1 Examples: configs - | config | - | basic_onefile | - | basic_folder | - | basic_dayone | + | config_file | + | basic_onefile.yaml | + | basic_folder.yaml | + | basic_dayone.yaml | Scenario Outline: Emails addresses should not be parsed as tags - Given we use the config ".yaml" + Given we use the config "" When we run "jrnl 2020-09-26: The email address test@example.com does not seem to work for me" When we run "jrnl 2020-09-26: The email address test@example.org also does not work for me" When we run "jrnl 2020-09-26: I tried test@example.org and test@example.edu too" - Then we flush the output When we run "jrnl --tags -on 2020-09-26" Then we should get no error And the output should be "[No tags found in journal.]" Examples: configs - | config | - | basic_onefile | - | basic_folder | - | basic_dayone | + | config_file | + | basic_onefile.yaml | + | basic_folder.yaml | + | basic_dayone.yaml | Scenario Outline: Entry can start and end with tags - Given we use the config ".yaml" + Given we use the config "" When we run "jrnl 2020-09-26: @foo came over, we went to a @bar" When we run "jrnl --tags -on 2020-09-26" Then the output should be - """ - @foo : 1 - @bar : 1 - """ + @foo : 1 + @bar : 1 Examples: configs - | config | - | basic_onefile | - | basic_folder | - | basic_dayone | + | config_file | + | basic_onefile.yaml | + | basic_folder.yaml | + | basic_dayone.yaml | diff --git a/tests/step_defs/conftest.py b/tests/step_defs/conftest.py index 4c1d42d4..ea561ba0 100644 --- a/tests/step_defs/conftest.py +++ b/tests/step_defs/conftest.py @@ -419,14 +419,15 @@ def output_should_not_contain(output, cli_run): assert output not in cli_run["stdout"] -@then(parse("the output should be\n{output}")) -@then(parse('the output should be "{output}"')) -@then('the output should be ""') -def output_should_be(output, cli_run): +@then(parse("the output should be\n{str_value}")) +@then(parse('the output should be "{str_value}"')) +@then('the output should be ""') +@then("the output should be empty") +def output_should_be(str_value, cli_run): actual_out = cli_run["stdout"].strip() - output = output.strip() - assert output and output == actual_out, failed_msg( - "Output does not match.", output, actual_out + expected = str_value.strip() + assert expected == actual_out, failed_msg( + "Output does not match.", expected, actual_out )