diff --git a/features/core.feature b/features/core.feature index 854fa53f..598b99f8 100644 --- a/features/core.feature +++ b/features/core.feature @@ -20,12 +20,20 @@ Feature: Basic reading and writing to a journal When we run "jrnl -n 1" Then the output should contain "2013-07-23 09:00 A cold and stormy day." - # Note that the expected output is actually "[Nothing saved to file]" but due to mocking limitations, we expect no output here. Scenario: Writing an empty entry from the editor Given we use the config "editor.yaml" When we open the editor and enter "" Then we should see the message "[Nothing saved to file]" + Scenario: Writing an empty entry from the command line + Given we use the config "basic.yaml" + When we run "jrnl ''" + Then we should get no error + And the unstripped output should be + """ + + """ + Scenario: Filtering for dates Given we use the config "basic.yaml" When we run "jrnl -on 2013-06-10 --short" diff --git a/features/steps/core.py b/features/steps/core.py index 847cbeaf..40b44f92 100644 --- a/features/steps/core.py +++ b/features/steps/core.py @@ -211,6 +211,15 @@ def check_output(context, text=None): for line_text, line_out in zip(text, out): assert line_text.strip() == line_out.strip(), [line_text.strip(), line_out.strip()] +@then('the unstripped output should be') +@then('the unstripped output should be "{text}"') +def check_output(context, text=None): + text = (text or context.text).splitlines() + out = context.stdout_capture.getvalue().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 == line_out, [line_text, line_out] + @then('the output should contain "{text}" in the local time') def check_output_time_inline(context, text):