From 1822f50c7073a76ae7d36971ddad1e291b8beba7 Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Mon, 21 Jul 2014 13:30:36 +0900 Subject: [PATCH] Tests for date parsing and `-on` --- features/core.feature | 7 +++++++ features/steps/core.py | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/features/core.feature b/features/core.feature index 61a6bf57..3a9b9c7c 100644 --- a/features/core.feature +++ b/features/core.feature @@ -20,6 +20,13 @@ 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." + Scenario: Filtering for dates + Given we use the config "basic.json" + When we run "jrnl -on 2013-06-10 --short" + Then the output should be "2013-06-10 15:40 Life is good." + When we run "jrnl -on 'june 6 2013' --short" + Then the output should be "2013-06-10 15:40 Life is good." + Scenario: Emoji support Given we use the config "basic.json" When we run "jrnl 23 july 2013: 🌞 sunny day. Saw an 🐘" diff --git a/features/steps/core.py b/features/steps/core.py index cdde7613..c4aa2f59 100644 --- a/features/steps/core.py +++ b/features/steps/core.py @@ -110,9 +110,11 @@ def check_output_field_key(context, field, key): assert field in out_json assert key in out_json[field] + @then('the output should be') -def check_output(context): - text = context.text.strip().splitlines() +@then('the output should be "{text}"') +def check_output(context, text=None): + text = (text or 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):