diff --git a/tests/features/file_storage.feature b/tests/features/file_storage.feature index dc6fd535..f81f2710 100644 --- a/tests/features/file_storage.feature +++ b/tests/features/file_storage.feature @@ -44,9 +44,9 @@ Feature: Journals iteracting with the file system in a way that users can see Given we use the config "editor.yaml" When we run "jrnl --edit" Then the editor should have been called - Then the temporary filename suffix should be ".jrnl" + Then the editor filename should end with ".jrnl" Scenario: the temporary filename suffix should be "-{template_filename}" Given we use the config "editor_markdown_extension.yaml" When we run "jrnl --edit" - Then the temporary filename suffix should be "-extension.md" + Then the editor filename should end with "-extension.md" diff --git a/tests/step_defs/conftest.py b/tests/step_defs/conftest.py index 2c58c382..57a0de03 100644 --- a/tests/step_defs/conftest.py +++ b/tests/step_defs/conftest.py @@ -141,11 +141,13 @@ def temp_dir(): def working_dir(request): return os.path.join(request.config.rootpath, "tests") + @fixture def config_path(temp_dir): os.chdir(temp_dir.name) return temp_dir.name + "/jrnl.yaml" + @fixture def toml_version(working_dir): pyproject = os.path.join(working_dir, "..", "pyproject.toml") @@ -201,7 +203,7 @@ def keyring_type(): @fixture def config_data(config_path): return load_config(config_path) - + @fixture def journal_name(): @@ -304,6 +306,13 @@ def count_editor_args(num_args, cli_run, editor_state): assert len(editor_state["command"]) == int(num_args) +@then(parse('the editor filename should end with "{suffix}"')) +def editor_filename_suffix(suffix, editor_state): + editor_filename = editor_state["tmpfile"]["name"] + + assert editor_state["tmpfile"]["name"].endswith(suffix), (editor_filename, suffix) + + @then(parse('the editor file content should {comparison} "{str_value}"')) @then(parse("the editor file content should {comparison} empty")) @then(parse("the editor file content should {comparison}\n{str_value}"))