diff --git a/features/core.feature b/features/core.feature index 45aa5e26..466a1851 100644 --- a/features/core.feature +++ b/features/core.feature @@ -1,10 +1,10 @@ Feature: Basic reading and writing to a journal Scenario: Loading a sample journal - Given we use "basic.json" + Given we use the config "basic.json" When we run "jrnl -n 2" Then we should get no error - Then the output should be + And the output should be """ 2013-06-09 15:39 My first entry. | Everything is alright @@ -12,3 +12,10 @@ Feature: Basic reading and writing to a journal 2013-06-10 15:40 Life is good. | But I'm better. """ + + Scenario: Writing an entry from command line + Given we use the config "basic.json" + When we run "jrnl 23 july 2013: A cold and stormy day. I ate crisps on the sofa." + Then the output should contain "Entry added" + When we run "jrnl -n 1" + Then the output should contain "2013-07-23 09:00 A cold and stormy day." diff --git a/features/steps/core.py b/features/steps/core.py index 44893d41..a4fa5c55 100644 --- a/features/steps/core.py +++ b/features/steps/core.py @@ -2,7 +2,7 @@ from behave import * from jrnl import Journal, jrnl import os -@given('we use "{config_file}"') +@given('we use the config "{config_file}"') def set_config(context, config_file): full_path = os.path.join("features/configs", config_file) jrnl.CONFIG_PATH = os.path.abspath(full_path) @@ -22,3 +22,9 @@ def check_output(context): out = context.stdout_capture.getvalue().strip().splitlines() for line_text, line_out in zip(text, out): assert line_text.strip() == line_out.strip() + +@then('the output should contain "{text}"') +def check_output(context, text): + out = context.stdout_capture.getvalue() + print out + assert text in out