standardize behave tests

This commit is contained in:
Jonathan Wren 2020-07-06 23:08:30 -07:00
parent 6b73eb786e
commit 131477c7e3
No known key found for this signature in database
GPG key ID: 43D5FF8722E7F68A
15 changed files with 291 additions and 309 deletions

View file

@ -4,7 +4,7 @@ Feature: Contains
Given we use the config "basic.yaml"
When we run "jrnl -contains life"
Then we should get no error
and the output should be
And the output should be
"""
2013-06-10 15:40 Life is good.
| But I'm better.
@ -20,10 +20,10 @@ Feature: Contains
Given we use the config "tags.yaml"
When we run "jrnl -and @journal @idea -contains software"
Then we should get no error
and the output should contain "software"
And the output should contain "software"
Scenario: Searching for a string within NOT tag results
Given we use the config "tags.yaml"
When we run "jrnl -not @dan -contains software"
Then we should get no error
and the output should contain "software"
And the output should contain "software"

View file

@ -4,7 +4,7 @@ Feature: Basic reading and writing to a journal
Given we use the config "basic.yaml"
When we run "jrnl -n 2"
Then we should get no error
and the output should be
And the output should be
"""
2013-06-09 15:39 My first entry.
| Everything is alright
@ -17,7 +17,7 @@ Feature: Basic reading and writing to a journal
Given we use the config "multiline.yaml"
When we run "jrnl -n 1"
Then we should get no error
and the output should be
And the output should be
"""
2013-06-09 15:39 Multiple line entry.
| This is the first line.
@ -29,13 +29,13 @@ Feature: Basic reading and writing to a journal
Scenario: Multiline entry with punctuation
Given we use the config "basic.yaml"
When we run "jrnl This is. the title\\n This is the second line"
and we run "jrnl -n 1"
And we run "jrnl -n 1"
Then the output should contain "This is. the title"
Scenario: Single line entry with punctuation
Given we use the config "basic.yaml"
When we run "jrnl This is. the title"
and we run "jrnl -n 1"
And we run "jrnl -n 1"
Then the output should contain "| the title"
Scenario: Writing an entry from command line
@ -62,10 +62,7 @@ Feature: Basic reading and writing to a journal
Scenario: Writing an empty entry from the command line
Given we use the config "basic.yaml"
When we run "jrnl" and enter nothing
Then the output should be
"""
"""
Then the output should be empty
Scenario: Filtering for dates
Given we use the config "basic.yaml"
@ -80,14 +77,14 @@ Feature: Basic reading and writing to a journal
Then we should see the message "Entry added"
When we run "jrnl -n 1"
Then the output should contain "🌞"
and the output should contain "🐘"
And the output should contain "🐘"
Scenario: Writing an entry at the prompt
Given we use the config "basic.yaml"
When we run "jrnl" and enter "25 jul 2013: I saw Elvis. He's alive."
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."
And the journal should contain "[2013-07-25 09:00] I saw Elvis."
And the journal should contain "He's alive."
Scenario: Displaying the version number
Given we use the config "basic.yaml"
@ -117,7 +114,7 @@ Feature: Basic reading and writing to a journal
Scenario: Journal directory does not exist
Given we use the config "missing_directory.yaml"
When we run "jrnl Life is good"
and we run "jrnl -n 1"
And we run "jrnl -n 1"
Then the output should contain "Life is good"
Scenario: Installation with relative journal and referencing from another folder
@ -127,8 +124,8 @@ Feature: Basic reading and writing to a journal
test.txt
n
"""
and we change directory to "features"
and we run "jrnl -n 1"
And we change directory to "features"
And we run "jrnl -n 1"
Then the output should contain "hello world"
Scenario: --diagnostic runs without exceptions

View file

@ -4,7 +4,7 @@ Feature: Dayone specific implementation details.
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
And the output should be
"""
2013-05-17 11:39 This entry has tags!
@ -19,16 +19,13 @@ Feature: Dayone specific implementation details.
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
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.
"""
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"
@ -42,7 +39,7 @@ Feature: Dayone specific implementation details.
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"
And we run "jrnl --tags"
Then the output should be
"""
@work : 2
@ -52,44 +49,23 @@ Feature: Dayone specific implementation details.
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!
"""
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"
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"
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"
Scenario: Editing Dayone with mock editor
Given we use the config "dayone.yaml"
When we run "jrnl --edit"
Then we should get no error
Scenario: Editing Dayone entries
Given we use the config "dayone.yaml"
When we open the editor and append
"""
Here is the first line.
Here is the second line.
"""
When we run "jrnl -n 1"
Then we should get no error
and the output should contain "This entry is starred!"
and the output should contain "Here is the first line"
and the output should contain "Here is the second line"
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"

View file

@ -6,10 +6,7 @@ Feature: Zapped Dayone bugs stay dead!
# 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!
"""
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

View file

@ -1,25 +1,22 @@
Feature: Delete entries from journal
Scenario: --delete flag allows deletion of single entry
Given we use the config "deletion.yaml"
Then the journal should have 3 entries
When we run "jrnl -n 1"
Then the output should contain
"""
2019-10-29 11:13 Third entry.
"""
Then the output should contain "2019-10-29 11:13 Third entry."
When we run "jrnl --delete" and enter
"""
N
N
Y
"""
Then the journal should have 2 entries
When we run "jrnl -n 1"
Then the output should contain
"""
2019-10-29 11:11 Second entry.
"""
Then the output should contain "2019-10-29 11:11 Second entry."
Scenario: Backing out of interactive delete does not change journal
Given we use the config "deletion.yaml"
Then the journal should have 3 entries
When we run "jrnl --delete -n 1" and enter
"""
N
@ -31,119 +28,125 @@ Feature: Delete entries from journal
Scenario: --delete flag with nonsense input deletes nothing (issue #932)
Given we use the config "deletion.yaml"
Then the journal should have 3 entries
When we run "jrnl --delete asdfasdf"
Then the journal should have 3 entries
When we run "jrnl -n 1"
Then the output should contain
"""
2019-10-29 11:13 Third entry.
"""
And the journal should have 3 entries
Then the output should contain "2019-10-29 11:13 Third entry."
Scenario: --delete flag with tag only deletes tagged entries
Given we use the config "deletion_filters.yaml"
Then the journal should have 5 entries
When we run "jrnl --delete @holidays" and enter
"""
Y
Y
"""
Then the journal should have 3 entries
Then the journal should contain "[2019-10-01 08:00] It's just another day in October."
and the journal should contain "[2020-03-01 08:00] It's just another day in March."
and the journal should contain "[2020-05-02 12:10] Writing tests."
And the journal should contain "[2019-10-01 08:00] It's just another day in October."
And the journal should contain "[2020-03-01 08:00] It's just another day in March."
And the journal should contain "[2020-05-02 12:10] Writing tests."
Scenario: --delete flag with multiple tags deletes all entries matching any of the tags
Given we use the config "deletion_filters.yaml"
Then the journal should have 5 entries
When we run "jrnl --delete @holidays @springtime" and enter
"""
Y
Y
Y
"""
Then the journal should contain "[2019-10-01 08:00] It's just another day in October."
and the journal should not contain "[2020-01-01 08:00] Happy New Year!"
and the journal should contain "[2020-03-01 08:00] It's just another day in March."
and the journal should not contain "[2020-05-01 09:00] Happy May Day!"
and the journal should not contain "[2020-05-02 12:10] Writing tests. *"
and the journal should have 2 entries
Then the journal should have 2 entries
And the journal should contain "[2019-10-01 08:00] It's just another day in October."
And the journal should contain "[2020-03-01 08:00] It's just another day in March."
But the journal should not contain "[2020-01-01 08:00] Happy New Year!"
But the journal should not contain "[2020-05-01 09:00] Happy May Day!"
But the journal should not contain "[2020-05-02 12:10] Writing tests. *"
Scenario: --delete flag with -and and tags only deletes boolean AND of tagged entries
Given we use the config "deletion_filters.yaml"
Then the journal should have 5 entries
When we run "jrnl --delete -and @holidays @springtime" and enter
"""
Y
"""
Then the journal should contain "[2019-10-01 08:00] It's just another day in October."
and the journal should contain "[2020-01-01 08:00] Happy New Year!"
and the journal should contain "[2020-03-01 08:00] It's just another day in March."
and the journal should not contain "[2020-05-01 09:00] Happy May Day!"
and the journal should contain "[2020-05-02 12:10] Writing tests. *"
and the journal should have 4 entries
Then the journal should have 4 entries
And the journal should contain "[2019-10-01 08:00] It's just another day in October."
And the journal should contain "[2020-01-01 08:00] Happy New Year!"
And the journal should contain "[2020-03-01 08:00] It's just another day in March."
And the journal should contain "[2020-05-02 12:10] Writing tests. *"
But the journal should not contain "[2020-05-01 09:00] Happy May Day!"
Scenario: --delete flag with -not does not delete entries with -not tag
Given we use the config "deletion_filters.yaml"
Then the journal should have 5 entries
When we run "jrnl --delete @holidays -not @springtime" and enter
"""
Y
"""
Then the journal should contain "[2019-10-01 08:00] It's just another day in October."
and the journal should not contain "[2020-01-01 08:00] Happy New Year!"
and the journal should contain "[2020-03-01 08:00] It's just another day in March."
and the journal should contain "[2020-05-01 09:00] Happy May Day!"
and the journal should contain "[2020-05-02 12:10] Writing tests. *"
and the journal should have 4 entries
Then the journal should have 4 entries
And the journal should contain "[2019-10-01 08:00] It's just another day in October."
And the journal should contain "[2020-03-01 08:00] It's just another day in March."
And the journal should contain "[2020-05-01 09:00] Happy May Day!"
And the journal should contain "[2020-05-02 12:10] Writing tests. *"
But the journal should not contain "[2020-01-01 08:00] Happy New Year!"
Scenario: --delete flag with -from only deletes entries since a specified date
Given we use the config "deletion_filters.yaml"
Then the journal should have 5 entries
When we run "jrnl --delete -from 2020-01-02" and enter
"""
Y
Y
Y
"""
Then the journal should contain "[2019-10-01 08:00] It's just another day in October."
and the journal should contain "[2020-01-01 08:00] Happy New Year!"
and the journal should not contain "[2020-03-01 08:00] It's just another day in March."
and the journal should not contain "[2020-05-01 09:00] Happy May Day!"
and the journal should not contain "[2020-05-02 12:10] Writing tests."
and the journal should have 2 entries
Then the journal should have 2 entries
And the journal should contain "[2019-10-01 08:00] It's just another day in October."
And the journal should contain "[2020-01-01 08:00] Happy New Year!"
And the journal should not contain "[2020-03-01 08:00] It's just another day in March."
And the journal should not contain "[2020-05-01 09:00] Happy May Day!"
And the journal should not contain "[2020-05-02 12:10] Writing tests."
Scenario: --delete flag with -to only deletes entries up to specified date
Given we use the config "deletion_filters.yaml"
Then the journal should have 5 entries
When we run "jrnl --delete -to 2020-01-02" and enter
"""
Y
Y
"""
Then the journal should not contain "[2019-10-01 08:00] It's just another day in October."
and the journal should not contain "[2020-01-01 08:00] Happy New Year!"
and the journal should contain "[2020-03-01 08:00] It's just another day in March."
and the journal should contain "[2020-05-01 09:00] Happy May Day!"
and the journal should contain "[2020-05-02 12:10] Writing tests."
and the journal should have 3 entries
Then the journal should have 3 entries
And the journal should contain "[2020-03-01 08:00] It's just another day in March."
And the journal should contain "[2020-05-01 09:00] Happy May Day!"
And the journal should contain "[2020-05-02 12:10] Writing tests."
But the journal should not contain "[2019-10-01 08:00] It's just another day in October."
But the journal should not contain "[2020-01-01 08:00] Happy New Year!"
Scenario: --delete flag with -starred only deletes starred entries
Given we use the config "deletion_filters.yaml"
Then the journal should have 5 entries
When we run "jrnl --delete -starred" and enter
"""
Y
"""
Then the journal should contain "[2019-10-01 08:00] It's just another day in October."
and the journal should contain "[2020-01-01 08:00] Happy New Year!"
and the journal should contain "[2020-03-01 08:00] It's just another day in March."
and the journal should contain "[2020-05-01 09:00] Happy May Day!"
and the journal should not contain "[2020-05-02 12:10] Writing tests. *"
and the journal should have 4 entries
Then the journal should have 4 entries
And the journal should contain "[2019-10-01 08:00] It's just another day in October."
And the journal should contain "[2020-01-01 08:00] Happy New Year!"
And the journal should contain "[2020-03-01 08:00] It's just another day in March."
And the journal should contain "[2020-05-01 09:00] Happy May Day!"
But the journal should not contain "[2020-05-02 12:10] Writing tests. *"
Scenario: --delete flag with -contains only entries containing expression
Given we use the config "deletion_filters.yaml"
Then the journal should have 5 entries
When we run "jrnl --delete -contains happy" and enter
"""
Y
Y
"""
Then the journal should contain "[2019-10-01 08:00] It's just another day in October."
and the journal should not contain "[2020-01-01 08:00] Happy New Year!"
and the journal should contain "[2020-03-01 08:00] It's just another day in March."
and the journal should not contain "[2020-05-01 09:00] Happy May Day!"
and the journal should contain "[2020-05-02 12:10] Writing tests. *"
and the journal should have 3 entries
Then the journal should have 3 entries
And the journal should contain "[2019-10-01 08:00] It's just another day in October."
And the journal should contain "[2020-03-01 08:00] It's just another day in March."
And the journal should contain "[2020-05-02 12:10] Writing tests. *"
But the journal should not contain "[2020-01-01 08:00] Happy New Year!"
But the journal should not contain "[2020-05-01 09:00] Happy May Day!"

View file

@ -9,7 +9,7 @@
Given we use the config "encrypted.yaml"
When we run "jrnl --decrypt" and enter "bad doggie no biscuit"
Then the config for journal "default" should have "encrypt" set to "bool:False"
Then we should see the message "Journal decrypted"
And we should see the message "Journal decrypted"
And the journal should have 2 entries
Scenario: Encrypting a journal
@ -55,12 +55,13 @@
Then the config for journal "simple" should have "encrypt" set to "bool:True"
When we run "jrnl simple -n 1"
Then the output should contain "2013-06-10 15:40 Life is good"
But the output should not contain "Password"
Scenario: Encrypt journal with no keyring backend and do not store in keyring
Given we use the config "basic.yaml"
When we disable the keychain
and we run "jrnl test entry"
and we run "jrnl --encrypt" and enter
And we run "jrnl test entry"
And we run "jrnl --encrypt" and enter
"""
password
password
@ -71,8 +72,8 @@
Scenario: Encrypt journal with no keyring backend and do store in keyring
Given we use the config "basic.yaml"
When we disable the keychain
and we run "jrnl test entry"
and we run "jrnl --encrypt" and enter
And we run "jrnl test entry"
And we run "jrnl --encrypt" and enter
"""
password
password

View file

@ -17,7 +17,7 @@ def before_feature(context, feature):
# add "skip" tag
# https://stackoverflow.com/a/42721605/4276230
if "skip" in feature.tags:
feature.skip("")
feature.skip()
return
if "skip_win" in feature.tags and on_windows:
@ -44,7 +44,7 @@ def before_scenario(context, scenario):
# add "skip" tag
# https://stackoverflow.com/a/42721605/4276230
if "skip" in scenario.effective_tags:
scenario.skip("")
scenario.skip()
return
if "skip_win" in scenario.effective_tags and on_windows:

View file

@ -23,7 +23,7 @@ Feature: Exporting a Journal
Scenario: Exporting using custom templates
Given we use the config "basic.yaml"
Given we load template "sample.template"
And we load template "sample.template"
When we run "jrnl --export sample"
Then the output should be
"""

View file

@ -5,10 +5,7 @@ Feature: Testing a journal with a root directory and multiple files in the forma
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.
"""
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"

View file

@ -3,19 +3,19 @@ Feature: Multiple journals
Scenario: Loading a config with two journals
Given we use the config "multiple.yaml"
Then journal "default" should have 2 entries
and journal "work" should have 0 entries
And journal "work" should have 0 entries
Scenario: Write to default config by default
Given we use the config "multiple.yaml"
When we run "jrnl this goes to default"
Then journal "default" should have 3 entries
and journal "work" should have 0 entries
And journal "work" should have 0 entries
Scenario: Write to specified journal
Given we use the config "multiple.yaml"
When we run "jrnl work a long day in the office"
Then journal "default" should have 2 entries
and journal "work" should have 1 entry
And journal "work" should have 1 entry
Scenario: Tell user which journal was used
Given we use the config "multiple.yaml"
@ -26,8 +26,8 @@ Feature: Multiple journals
Given we use the config "multiple.yaml"
When we run "jrnl work 23 july 2012: a long day in the office"
Then journal "default" should have 2 entries
and journal "work" should have 1 entry
and journal "work" should contain "2012-07-23"
And journal "work" should have 1 entry
And journal "work" should contain "2012-07-23"
Scenario: Create new journals as required
Given we use the config "multiple.yaml"

View file

@ -13,14 +13,14 @@ Feature: Zapped bugs should stay dead.
Given we use the config "basic.yaml"
When we run "jrnl 2013-11-30 15:42: Project Started."
Then we should see the message "Entry added"
and the journal should contain "[2013-11-30 15:42] Project Started."
And the journal should contain "[2013-11-30 15:42] Project Started."
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
And the output should be
"""
2013-10-27 03:27 Some text.
"""
@ -30,7 +30,7 @@ Feature: Zapped bugs should stay dead.
Given we use the config "basic.yaml"
When we run "jrnl 26/06/2019: Planet? Earth. Year? 2019."
Then we should see the message "Entry added"
and the journal should contain "[2019-06-26 09:00] Planet?"
And the journal should contain "[2019-06-26 09:00] Planet?"
Scenario: Empty DayOne entry bodies should not error
# https://github.com/jrnl-org/jrnl/issues/780
@ -58,7 +58,7 @@ Feature: Zapped bugs should stay dead.
Given we use the config "unreadabledates.yaml"
When we run "jrnl -2"
Then the output should contain "I've lost track of time."
Then the output should contain "Time has no meaning."
And the output should contain "Time has no meaning."
Scenario: Journals with readable dates AND unreadable dates should still contain all data.
Given we use the config "mostlyreadabledates.yaml"
@ -66,14 +66,14 @@ Feature: Zapped bugs should stay dead.
Then the output should contain "Time machines are possible."
When we run "jrnl -1"
Then the output should contain "I'm going to activate the machine."
Then the output should contain "I've crossed so many timelines. Is there any going back?"
And the output should contain "I've crossed so many timelines. Is there any going back?"
Scenario: Viewing today's entries does not print the entire journal
# https://github.com/jrnl-org/jrnl/issues/741
Given we use the config "basic.yaml"
When we run "jrnl -on today"
Then the output should not contain "Life is good"
Then the output should not contain "But I'm better."
And the output should not contain "But I'm better."
Scenario: Create entry using day of the week as entry date.
Given we use the config "basic.yaml"
@ -81,7 +81,7 @@ Feature: Zapped bugs should stay dead.
Then we should see the message "Entry added"
When we run "jrnl -1"
Then the output should contain "monday at 9am" in the local time
Then the output should contain "This is an entry on a Monday."
And the output should contain "This is an entry on a Monday."
Scenario: Create entry using day of the week abbreviations as entry date.
Given we use the config "basic.yaml"
@ -107,8 +107,8 @@ Feature: Zapped bugs should stay dead.
Then we should see the message "Entry added"
When we run "jrnl -from today"
Then the output should contain "Adding an entry right now."
Then the output should contain "A future entry."
Then the output should not contain "This thing happened yesterday"
And the output should contain "A future entry."
And the output should not contain "This thing happened yesterday"
Scenario: Displaying entries using -from and -to day should display correct entries
Given we use the config "basic.yaml"
@ -120,8 +120,8 @@ Feature: Zapped bugs should stay dead.
Then we should see the message "Entry added"
When we run "jrnl -from yesterday -to today"
Then the output should contain "This thing happened yesterday"
Then the output should contain "Adding an entry right now."
Then the output should not contain "A future entry."
And the output should contain "Adding an entry right now."
And the output should not contain "A future entry."
# See issues #768 and #881
# the "deletion" journal is used because it doesn't have a newline at the
@ -146,7 +146,7 @@ Feature: Zapped bugs should stay dead.
"""
# See issues #768 and #881
Scenario: Add a blank line to YAML export is there isn't one already
Scenario: Add a blank line to YAML export if there isn't one already
Given we use the config "deletion.yaml"
And we create cache directory "bug768"
When we run "jrnl --export yaml -o {cache_dir}" with cache directory "bug768"
@ -172,4 +172,4 @@ Feature: Zapped bugs should stay dead.
Given we use the config "basic.yaml"
When we run "jrnl --version"
Then we should get no error
Then the output should contain pyproject.toml version
And the output should contain pyproject.toml version

View file

@ -4,17 +4,12 @@ Feature: Starring entries
Given we use the config "basic.yaml"
When we run "jrnl 20 july 2013 *: Best day of my life!"
Then we should see the message "Entry added"
and the journal should contain "[2013-07-20 09:00] Best day of my life! *"
And the journal should contain "[2013-07-20 09:00] Best day of my life! *"
Scenario: Filtering by starred entries
Given we use the config "basic.yaml"
When we run "jrnl -starred"
Then the output should be
"""
"""
Then the output should be empty
When we run "jrnl 20 july 2013 *: Best day of my life!"
When we run "jrnl -starred"
Then the output should be
"""
2013-07-20 09:00 Best day of my life!
"""
Then the output should be "2013-07-20 09:00 Best day of my life!"

View file

@ -270,9 +270,10 @@ def no_error(context):
@then("the output should be")
@then("the output should be empty")
@then('the output should be "{text}"')
def check_output(context, text=None):
text = (text or context.text).strip().splitlines()
text = (text or context.text or "").strip().splitlines()
out = context.stdout_capture.getvalue().strip().splitlines()
assert len(text) == len(out), "Output has {} lines (expected: {})".format(
len(out), len(text)
@ -359,9 +360,11 @@ def journal_doesnt_exist(context, journal_name="default"):
assert not os.path.exists(journal_path)
@then('the config should have "{key}" set to')
@then('the config should have "{key}" set to "{value}"')
@then('the config for journal "{journal}" should have "{key}" set to "{value}"')
def config_var(context, key, value, journal=None):
def config_var(context, key, value="", journal=None):
value = value or context.text or ""
if not value[0] == "{":
t, value = value.split(":")
value = {"bool": lambda v: v.lower() == "true", "int": int, "str": str}[t](

View file

@ -4,7 +4,7 @@ Feature: Tagging
Given we use the config "tags.yaml"
When we run "jrnl --tags"
Then we should get no error
and the output should be
And the output should be
"""
@idea : 2
@journal : 1
@ -15,7 +15,7 @@ Feature: Tagging
Given we use the config "tags.yaml"
When we run "jrnl -from 'may 2013' --tags"
Then we should get no error
and the output should be
And the output should be
"""
@idea : 1
@dan : 1
@ -25,17 +25,18 @@ Feature: Tagging
Given we use the config "tags-216.yaml"
When we run "jrnl --tags"
Then we should get no error
and the output should be
And the output should be
"""
@os/2 : 1
@c++ : 1
@c# : 1
"""
Scenario: An email should not be a tag
Given we use the config "tags-237.yaml"
When we run "jrnl --tags"
Then we should get no error
and the output should be
And the output should be
"""
@newline : 1
@email : 1
@ -74,10 +75,10 @@ Feature: Tagging
Scenario: Excluding multiple tags should filter them
Given we use the config "basic.yaml"
When we run "jrnl today: I do @not think this will show up @thought"
When we run "jrnl today: I think this will show up @thought"
When we run "jrnl today: This should @never show up @thought"
When we run "jrnl today: What a nice day for filtering @thought"
When we run "jrnl --tags -not @not -not @never"
And we run "jrnl today: I think this will show up @thought"
And we run "jrnl today: This should @never show up @thought"
And we run "jrnl today: What a nice day for filtering @thought"
And we run "jrnl --tags -not @not @never"
Then the output should be
"""
@thought : 2
@ -88,7 +89,7 @@ Feature: Tagging
Given we use the config "multiline-tags.yaml"
When we run "jrnl -n 1"
Then we should get no error
and the output should be
And the output should be
"""
2013-06-09 15:39 Multiple @line entry with @tags.
| Tag with @punctuation. afterwards

View file

@ -3,13 +3,15 @@ Feature: Upgrading Journals from 1.x.x to 2.x.x
Scenario: Upgrade and parse journals with square brackets
Given we use the config "upgrade_from_195.json"
When we run "jrnl -9" and enter "Y"
Then the output should contain
Then the journal should have 2 entries
And the output should contain
"""
2010-06-10 15:00 A life without chocolate is like a bad analogy.
"""
And the output should contain
"""
2013-06-10 15:40 He said "[this] is the best time to be alive".
"""
Then the journal should have 2 entries
Scenario: Upgrading a journal encrypted with jrnl 1.x
Given we use the config "encrypted_old.json"
@ -20,23 +22,33 @@ Feature: Upgrading Journals from 1.x.x to 2.x.x
bad doggie no biscuit
"""
Then the output should contain "Password"
and the output should contain "2013-06-10 15:40 Life is good"
And the output should contain "2013-06-10 15:40 Life is good"
Scenario: Upgrading a config without colors to colors
Given we use the config "no_colors.yaml"
When we run "jrnl -n 1"
Then the config should have "colors" set to "{'date':'none', 'title':'none', 'body':'none', 'tags':'none'}"
Then the config should have "colors" set to
"""
{
'date':'none',
'title':'none',
'body':'none',
'tags':'none'
}
"""
Scenario: Upgrade and parse journals with little endian date format
Given we use the config "upgrade_from_195_little_endian_dates.json"
When we run "jrnl -9" and enter "Y"
Then the output should contain
Then the journal should have 2 entries
And the output should contain
"""
10.06.2010 15:00 A life without chocolate is like a bad analogy.
"""
And the output should contain
"""
10.06.2013 15:40 He said "[this] is the best time to be alive".
"""
Then the journal should have 2 entries
Scenario: Upgrade with missing journal
Given we use the config "upgrade_from_195_with_missing_journal.json"