From 540c298565cba4505cff263c142f1653d1c64e79 Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Sun, 3 Nov 2013 15:57:20 -1000 Subject: [PATCH] Tests for starring --- features/starring.feature | 20 ++++++++++++++++++++ features/steps/core.py | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 features/starring.feature diff --git a/features/starring.feature b/features/starring.feature new file mode 100644 index 00000000..0f984896 --- /dev/null +++ b/features/starring.feature @@ -0,0 +1,20 @@ +Feature: Starring entries + + Scenario: Starring an entry will mark it in the journal file + Given we use the config "basic.json" + 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! *" + + Scenario: Filtering by starred entries + Given we use the config "basic.json" + When we run "jrnl -starred" + Then the output should be + """ + """ + 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! + """ diff --git a/features/steps/core.py b/features/steps/core.py index c66a921f..f97d7ae1 100644 --- a/features/steps/core.py +++ b/features/steps/core.py @@ -113,6 +113,7 @@ def check_output_field_key(context, field, key): def check_output(context): text = context.text.strip().splitlines() out = context.stdout_capture.getvalue().strip().splitlines() + assert len(text) == len(out), "Output has {} lines (expected: {})".format(len(out), len(text)) for line_text, line_out in zip(text, out): assert line_text.strip() == line_out.strip(), [line_text.strip(), line_out.strip()] @@ -149,7 +150,7 @@ def check_not_message(context, text): @then('journal "{journal_name}" should contain "{text}"') def check_journal_content(context, text, journal_name="default"): journal = read_journal(journal_name) - assert text in journal + assert text in journal, journal @then('journal "{journal_name}" should not exist') def journal_doesnt_exist(context, journal_name="default"):