From ccb55392dd6dc7d539adbbd7142429965e694e35 Mon Sep 17 00:00:00 2001 From: Aaron Lichtman Date: Sat, 16 Nov 2019 13:18:14 +0100 Subject: [PATCH] Check message on stderr and patch subprocess.call --- features/core.feature | 4 ++-- features/steps/core.py | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/features/core.feature b/features/core.feature index 2f62c19b..854fa53f 100644 --- a/features/core.feature +++ b/features/core.feature @@ -23,8 +23,8 @@ Feature: Basic reading and writing to a journal # 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 exit - Then the output should be empty + When we open the editor and enter "" + Then we should see the message "[Nothing saved to file]" Scenario: Filtering for dates Given we use the config "basic.yaml" diff --git a/features/steps/core.py b/features/steps/core.py index 8bc73313..d4bf1b47 100644 --- a/features/steps/core.py +++ b/features/steps/core.py @@ -67,9 +67,11 @@ def set_config(context, config_file): cf.write("version: {}".format(__version__)) -@when('we open the editor and exit') -def open_editor_and_exit_without_entering_text(context): - with patch('jrnl.util.get_text_from_editor', return_value=""): +@when('we open the editor and enter') +@when('we open the editor and enter {text}') +def open_editor_and_enter(context, text=""): + text = (text or context.text) + with patch('subprocess.call', return_value=text): run(context, "jrnl")