From 80bc2ae4ae974b39472ba674d4ae1295d271b3b7 Mon Sep 17 00:00:00 2001 From: Jonathan Wren Date: Sat, 19 Sep 2020 11:40:24 -0700 Subject: [PATCH] move tests to be more behavior driven --- features/datetime.feature | 21 ++++ features/file_storage.feature | 35 ++++++ features/format.feature | 26 +++++ features/journaltype.feature | 34 ++++++ features/journaltype_dayone.feature | 109 ------------------ features/journaltype_default.feature | 51 -------- features/journaltype_directory.feature | 39 ------- features/journaltype_encrypted.feature | 37 ------ .../{keyring.feature => password.feature} | 36 ++++++ features/search.feature | 21 ++++ features/tag.feature | 24 ++++ features/write.feature | 31 +++++ 12 files changed, 228 insertions(+), 236 deletions(-) create mode 100644 features/file_storage.feature create mode 100644 features/journaltype.feature delete mode 100644 features/journaltype_dayone.feature delete mode 100644 features/journaltype_default.feature delete mode 100644 features/journaltype_directory.feature delete mode 100644 features/journaltype_encrypted.feature rename features/{keyring.feature => password.feature} (52%) diff --git a/features/datetime.feature b/features/datetime.feature index f1b2ebde..b39f09b7 100644 --- a/features/datetime.feature +++ b/features/datetime.feature @@ -84,4 +84,25 @@ Feature: Reading and writing to journal with custom date formats Then the output should contain "I'm going to activate the machine." And the output should contain "I've crossed so many timelines. Is there any going back?" + Scenario: Integers in square brackets should not be read as dates + Given we use the config "brackets.yaml" + When we run "jrnl -1" + Then the output should contain "[1] line starting with 1" + # broken still + @skip + Scenario: Dayone entries without timezone information are interpreted in current timezone + Given we use the config "dayone.yaml" + When we run "jrnl -until 'feb 2013'" + Then we should get no error + And the output should contain "2013-01-17T18:37Z" in the local time + + Scenario: Loading entry with ambiguous time stamp + #https://github.com/jrnl-org/jrnl/issues/153 + Given we use the config "bug153.yaml" + When we run "jrnl -1" + Then we should get no error + And the output should be + """ + 2013-10-27 03:27 Some text. + """ diff --git a/features/file_storage.feature b/features/file_storage.feature new file mode 100644 index 00000000..1bede588 --- /dev/null +++ b/features/file_storage.feature @@ -0,0 +1,35 @@ +Feature: Journals iteracting with the file system in a way that users can see + + Scenario: Adding entries to a Folder journal should generate date files + Given we use the config "empty_folder.yaml" + When we run "jrnl 23 July 2013: Testing folder journal." + Then we should see the message "Entry added" + When the journal directory is listed + Then the output should contain "2013/07/23.txt" or "2013\07\23.txt" + + Scenario: Adding multiple entries to a Folder journal should generate multiple date files + Given we use the config "empty_folder.yaml" + When we run "jrnl 23 July 2013: Testing folder journal." + And we run "jrnl 3/7/2014: Second entry of journal." + Then we should see the message "Entry added" + When the journal directory is listed + Then the output should contain "2013/07/23.txt" or "2013\07\23.txt" + Then the output should contain "2014/03/07.txt" or "2014\03\07.txt" + + Scenario: If the journal and it's parent directory don't exist, they should be created + Given we use the config "missing_directory.yaml" + Then the journal should not exist + When we run "jrnl This is a new entry in my journal" + Then the journal should exist + When we run "jrnl -n 1" + Then the output should contain "This is a new entry in my journal" + And the journal should have 1 entry + + Scenario: If the journal file doesn't exist, then it should be created + Given we use the config "missing_journal.yaml" + Then the journal should not exist + When we run "jrnl This is a new entry in my journal" + Then the journal should exist + When we run "jrnl -n 1" + Then the output should contain "This is a new entry in my journal" + And the journal should have 1 entry diff --git a/features/format.feature b/features/format.feature index 7482bcea..bfbde83f 100644 --- a/features/format.feature +++ b/features/format.feature @@ -192,3 +192,29 @@ Feature: Custom formats tags: """ + + Scenario: Printing a journal that has multiline entries + Given we use the config "multiline.yaml" + When we run "jrnl -n 1" + Then we should get no error + And the output should be + """ + 2013-06-09 15:39 Multiple line entry. + | This is the first line. + | This line doesn't have any ending punctuation + | + | There is a blank line above this. + """ + + Scenario: Exporting dayone to json + Given we use the config "dayone.yaml" + When we run "jrnl --export json" + Then we should get no error + And the output should be parsable as json + And the json output should contain entries.0.uuid = "4BB1F46946AD439996C9B59DE7C4DDC1" + + Scenario: Empty DayOne entry bodies should not error + # https://github.com/jrnl-org/jrnl/issues/780 + Given we use the config "bug780.yaml" + When we run "jrnl --short" + Then we should get no error diff --git a/features/journaltype.feature b/features/journaltype.feature new file mode 100644 index 00000000..3d844c10 --- /dev/null +++ b/features/journaltype.feature @@ -0,0 +1,34 @@ +Feature: Tests that don't fit anywhere else + + Scenario: Opening an folder that's not a DayOne folder should treat as folder journal + Given we use the config "empty_folder.yaml" + When we run "jrnl 23 july 2013: Testing folder journal." + Then we should see the message "Entry added" + When we run "jrnl -1" + Then the output should be "2013-07-23 09:00 Testing folder journal." + + Scenario: Loading a sample journal + Given we use the config "basic.yaml" + When we run "jrnl -2" + Then we should get no error + And the output should be + """ + 2013-06-09 15:39 My first entry. + | Everything is alright + + 2013-06-10 15:40 Life is good. + | But I'm better. + """ + + Scenario: Loading a DayOne Journal + Given we use the config "dayone.yaml" + When we run "jrnl -from 'feb 2013'" + Then we should get no error + And the output should be + """ + 2013-05-17 11:39 This entry has tags! + + 2013-06-17 20:38 This entry has a location. + + 2013-07-17 11:38 This entry is starred! + """ diff --git a/features/journaltype_dayone.feature b/features/journaltype_dayone.feature deleted file mode 100644 index d4f3ff69..00000000 --- a/features/journaltype_dayone.feature +++ /dev/null @@ -1,109 +0,0 @@ -Feature: Dayone specific implementation details. - - Scenario: Loading a DayOne Journal - Given we use the config "dayone.yaml" - When we run "jrnl -from 'feb 2013'" - Then we should get no error - And the output should be - """ - 2013-05-17 11:39 This entry has tags! - - 2013-06-17 20:38 This entry has a location. - - 2013-07-17 11:38 This entry is starred! - """ - - # broken still - @skip - Scenario: Entries without timezone information will be interpreted as in the current timezone - Given we use the config "dayone.yaml" - When we run "jrnl -until 'feb 2013'" - Then we should get no error - And the output should contain "2013-01-17T18:37Z" in the local time - - Scenario: Writing into Dayone - Given we use the config "dayone.yaml" - When we run "jrnl 01 may 1979: Being born hurts." - And we run "jrnl -until 1980" - Then the output should be "1979-05-01 09:00 Being born hurts." - - Scenario: Loading tags from a DayOne Journal - Given we use the config "dayone.yaml" - When we run "jrnl --tags" - Then the output should be - """ - @work : 1 - @play : 1 - """ - - Scenario: Saving tags from a DayOne Journal - Given we use the config "dayone.yaml" - When we run "jrnl A hard day at @work" - And we run "jrnl --tags" - Then the output should be - """ - @work : 2 - @play : 1 - """ - - Scenario: Filtering by tags from a DayOne Journal - Given we use the config "dayone.yaml" - When we run "jrnl @work" - Then the output should be "2013-05-17 11:39 This entry has tags!" - - Scenario: Exporting dayone to json - Given we use the config "dayone.yaml" - When we run "jrnl --export json" - Then we should get no error - And the output should be parsable as json - And the json output should contain entries.0.uuid = "4BB1F46946AD439996C9B59DE7C4DDC1" - - Scenario: Writing into Dayone adds extended metadata - Given we use the config "dayone.yaml" - When we run "jrnl 01 may 1979: Being born hurts." - And we run "jrnl --export json" - Then "entries" in the json output should have 5 elements - And the json output should contain entries.0.creator.software_agent - And the json output should contain entries.0.creator.os_agent - And the json output should contain entries.0.creator.host_name - And the json output should contain entries.0.creator.generation_date - And the json output should contain entries.0.creator.device_agent - And "entries.0.creator.software_agent" in the json output should contain "jrnl" - - # fails when system time is UTC (as on Travis-CI) - @skip - Scenario: DayOne tag searching should work with tags containing a mixture of upper and lower case. - # https://github.com/jrnl-org/jrnl/issues/354 - Given we use the config "dayone.yaml" - When we run "jrnl @plAy" - Then the output should contain "2013-05-17 11:39 This entry has tags!" - - # fails when system time is UTC (as on Travis-CI) - @skip - Scenario: Title with an embedded period on DayOne journal - Given we use the config "dayone.yaml" - When we run "jrnl 04-24-2014: "Ran 6.2 miles today in 1:02:03. I'm feeling sore because I forgot to stretch."" - Then we should see the message "Entry added" - When we run "jrnl -1" - Then the output should be - """ - 2014-04-24 09:00 Ran 6.2 miles today in 1:02:03. - | I'm feeling sore because I forgot to stretch. - """ - - Scenario: Loading entry with ambiguous time stamp - #https://github.com/jrnl-org/jrnl/issues/153 - Given we use the config "bug153.yaml" - When we run "jrnl -1" - Then we should get no error - And the output should be - """ - 2013-10-27 03:27 Some text. - """ - - Scenario: Empty DayOne entry bodies should not error - # https://github.com/jrnl-org/jrnl/issues/780 - Given we use the config "bug780.yaml" - When we run "jrnl --short" - Then we should get no error - diff --git a/features/journaltype_default.feature b/features/journaltype_default.feature deleted file mode 100644 index 50a31c8f..00000000 --- a/features/journaltype_default.feature +++ /dev/null @@ -1,51 +0,0 @@ -Feature: Loading the default journal type - - Scenario: Loading a sample journal - Given we use the config "basic.yaml" - When we run "jrnl -2" - Then we should get no error - And the output should be - """ - 2013-06-09 15:39 My first entry. - | Everything is alright - - 2013-06-10 15:40 Life is good. - | But I'm better. - """ - - Scenario: Printing a journal that has multiline entries - Given we use the config "multiline.yaml" - When we run "jrnl -n 1" - Then we should get no error - And the output should be - """ - 2013-06-09 15:39 Multiple line entry. - | This is the first line. - | This line doesn't have any ending punctuation - | - | There is a blank line above this. - """ - - Scenario: Integers in square brackets should not be read as dates - Given we use the config "brackets.yaml" - When we run "jrnl -1" - Then the output should contain "[1] line starting with 1" - - - Scenario: If the journal and it's parent directory don't exist, they should be created - Given we use the config "missing_directory.yaml" - Then the journal should not exist - When we run "jrnl This is a new entry in my journal" - Then the journal should exist - When we run "jrnl -n 1" - Then the output should contain "This is a new entry in my journal" - And the journal should have 1 entry - - Scenario: If the journal file doesn't exist, then it should be created - Given we use the config "missing_journal.yaml" - Then the journal should not exist - When we run "jrnl This is a new entry in my journal" - Then the journal should exist - When we run "jrnl -n 1" - Then the output should contain "This is a new entry in my journal" - And the journal should have 1 entry diff --git a/features/journaltype_directory.feature b/features/journaltype_directory.feature deleted file mode 100644 index c1d0f320..00000000 --- a/features/journaltype_directory.feature +++ /dev/null @@ -1,39 +0,0 @@ -Feature: Testing a journal with a root directory and multiple files in the format of yyyy/mm/dd.txt - - Scenario: Opening an folder that's not a DayOne folder should treat as folder journal - Given we use the config "empty_folder.yaml" - When we run "jrnl 23 july 2013: Testing folder journal." - Then we should see the message "Entry added" - When we run "jrnl -1" - Then the output should be "2013-07-23 09:00 Testing folder journal." - - Scenario: Adding entries to a Folder journal should generate date files - Given we use the config "empty_folder.yaml" - When we run "jrnl 23 July 2013: Testing folder journal." - Then we should see the message "Entry added" - When the journal directory is listed - Then the output should contain "2013/07/23.txt" or "2013\07\23.txt" - - - Scenario: Adding multiple entries to a Folder journal should generate multiple date files - Given we use the config "empty_folder.yaml" - When we run "jrnl 23 July 2013: Testing folder journal." - And we run "jrnl 3/7/2014: Second entry of journal." - Then we should see the message "Entry added" - When the journal directory is listed - Then the output should contain "2013/07/23.txt" or "2013\07\23.txt" - Then the output should contain "2014/03/07.txt" or "2014\03\07.txt" - - Scenario: Out of order entries to a Folder journal should be listed in date order - Given we use the config "empty_folder.yaml" - When we run "jrnl 3/7/2014 4:37pm: Second entry of journal." - Then we should see the message "Entry added" - When we run "jrnl 23 July 2013: Testing folder journal." - Then we should see the message "Entry added" - When we run "jrnl -2" - Then the output should be - """ - 2013-07-23 09:00 Testing folder journal. - - 2014-03-07 16:37 Second entry of journal. - """ diff --git a/features/journaltype_encrypted.feature b/features/journaltype_encrypted.feature deleted file mode 100644 index e6fb5cfd..00000000 --- a/features/journaltype_encrypted.feature +++ /dev/null @@ -1,37 +0,0 @@ -Feature: Loading the encrypted journal type - - Scenario: Loading an encrypted journal - Given we use the config "encrypted.yaml" - When we run "jrnl -n 1" and enter "bad doggie no biscuit" - Then we should be prompted for a password - And the output should contain "2013-06-10 15:40 Life is good" - - Scenario: Mistyping your password - Given we use the config "basic.yaml" - When we run "jrnl --encrypt" and enter - """ - swordfish - sordfish - """ - Then we should be prompted for a password - And we should see the message "Passwords did not match" - And the config for journal "default" should not have "encrypt" set - And the journal should have 2 entries - - Scenario: Mistyping your password, then getting it right - Given we use the config "basic.yaml" - When we run "jrnl --encrypt" and enter - """ - swordfish - sordfish - swordfish - swordfish - n - """ - Then we should be prompted for a password - And we should see the message "Passwords did not match" - And we should see the message "Journal encrypted" - And the config for journal "default" should have "encrypt" set to "bool:True" - When we run "jrnl -n 1" and enter "swordfish" - Then we should be prompted for a password - And the output should contain "2013-06-10 15:40 Life is good" diff --git a/features/keyring.feature b/features/password.feature similarity index 52% rename from features/keyring.feature rename to features/password.feature index f29d72eb..e182c499 100644 --- a/features/keyring.feature +++ b/features/password.feature @@ -45,3 +45,39 @@ Feature: Using the installed keyring @todo Scenario: Open encrypted journal when keyring exists but fails # This should ask the user for the password after the keyring fails + + Scenario: Loading an encrypted journal + Given we use the config "encrypted.yaml" + When we run "jrnl -n 1" and enter "bad doggie no biscuit" + Then we should be prompted for a password + And the output should contain "2013-06-10 15:40 Life is good" + + Scenario: Mistyping your password + Given we use the config "basic.yaml" + When we run "jrnl --encrypt" and enter + """ + swordfish + sordfish + """ + Then we should be prompted for a password + And we should see the message "Passwords did not match" + And the config for journal "default" should not have "encrypt" set + And the journal should have 2 entries + + Scenario: Mistyping your password, then getting it right + Given we use the config "basic.yaml" + When we run "jrnl --encrypt" and enter + """ + swordfish + sordfish + swordfish + swordfish + n + """ + Then we should be prompted for a password + And we should see the message "Passwords did not match" + And we should see the message "Journal encrypted" + And the config for journal "default" should have "encrypt" set to "bool:True" + When we run "jrnl -n 1" and enter "swordfish" + Then we should be prompted for a password + And the output should contain "2013-06-10 15:40 Life is good" diff --git a/features/search.feature b/features/search.feature index e2fdd138..f04fe9de 100644 --- a/features/search.feature +++ b/features/search.feature @@ -70,3 +70,24 @@ Feature: Searching in a journal When we run "jrnl -on 'june 6 2013' --short" Then the output should be "2013-06-10 15:40 Life is good." + Scenario: Out of order entries to a Folder journal should be listed in date order + Given we use the config "empty_folder.yaml" + When we run "jrnl 3/7/2014 4:37pm: Second entry of journal." + Then we should see the message "Entry added" + When we run "jrnl 23 July 2013: Testing folder journal." + Then we should see the message "Entry added" + When we run "jrnl -2" + Then the output should be + """ + 2013-07-23 09:00 Testing folder journal. + + 2014-03-07 16:37 Second entry of journal. + """ + + # fails when system time is UTC (as on Travis-CI) + @skip + Scenario: DayOne tag searching should work with tags containing a mixture of upper and lower case. + # https://github.com/jrnl-org/jrnl/issues/354 + Given we use the config "dayone.yaml" + When we run "jrnl @plAy" + Then the output should contain "2013-05-17 11:39 This entry has tags!" diff --git a/features/tag.feature b/features/tag.feature index 20ada178..8cff30be 100644 --- a/features/tag.feature +++ b/features/tag.feature @@ -119,3 +119,27 @@ Feature: Tagging | (2) ??? | (3) PROFIT! """ + + Scenario: Loading tags from a DayOne Journal + Given we use the config "dayone.yaml" + When we run "jrnl --tags" + Then the output should be + """ + @work : 1 + @play : 1 + """ + + Scenario: Saving tags from a DayOne Journal + Given we use the config "dayone.yaml" + When we run "jrnl A hard day at @work" + And we run "jrnl --tags" + Then the output should be + """ + @work : 2 + @play : 1 + """ + + Scenario: Filtering by tags from a DayOne Journal + Given we use the config "dayone.yaml" + When we run "jrnl @work" + Then the output should be "2013-05-17 11:39 This entry has tags!" diff --git a/features/write.feature b/features/write.feature index b3a28d32..35f00525 100644 --- a/features/write.feature +++ b/features/write.feature @@ -69,3 +69,34 @@ Feature: Writing new entries. Then we should get no error And the journal should contain "[2013-07-25 09:00] I saw Elvis." And the journal should contain "He's alive." + + Scenario: Writing into Dayone + Given we use the config "dayone.yaml" + When we run "jrnl 01 may 1979: Being born hurts." + And we run "jrnl -until 1980" + Then the output should be "1979-05-01 09:00 Being born hurts." + + Scenario: Writing into Dayone adds extended metadata + Given we use the config "dayone.yaml" + When we run "jrnl 01 may 1979: Being born hurts." + And we run "jrnl --export json" + Then "entries" in the json output should have 5 elements + And the json output should contain entries.0.creator.software_agent + And the json output should contain entries.0.creator.os_agent + And the json output should contain entries.0.creator.host_name + And the json output should contain entries.0.creator.generation_date + And the json output should contain entries.0.creator.device_agent + And "entries.0.creator.software_agent" in the json output should contain "jrnl" + + # fails when system time is UTC (as on Travis-CI) + @skip + Scenario: Title with an embedded period on DayOne journal + Given we use the config "dayone.yaml" + When we run "jrnl 04-24-2014: "Ran 6.2 miles today in 1:02:03. I'm feeling sore because I forgot to stretch."" + Then we should see the message "Entry added" + When we run "jrnl -1" + Then the output should be + """ + 2014-04-24 09:00 Ran 6.2 miles today in 1:02:03. + | I'm feeling sore because I forgot to stretch. + """