mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-07-07 16:56:13 +02:00
Fix editor config when an argument with a space is used
This commit is contained in:
parent
cdaf1f5a36
commit
455720f788
4 changed files with 44 additions and 4 deletions
|
@ -39,6 +39,15 @@ Feature: Basic reading and writing to a journal
|
|||
When we open the editor and enter nothing
|
||||
Then we should see the message "[Nothing saved to file]"
|
||||
|
||||
Scenario: Sending an argument with spaces to the editor should work
|
||||
Given we use the config "editor-args.yaml"
|
||||
When we open the editor and enter "lorem ipsum"
|
||||
Then the editor should have been called with 5 arguments
|
||||
And the editor arguments should contain "vim"
|
||||
And the editor arguments should contain "-f"
|
||||
And the editor arguments should contain "-c"
|
||||
And the editor arguments should contain "setf markdown"
|
||||
|
||||
Scenario: Writing an empty entry from the command line
|
||||
Given we use the config "basic.yaml"
|
||||
When we run "jrnl" and enter nothing
|
||||
|
|
12
features/data/configs/editor-args.yaml
Normal file
12
features/data/configs/editor-args.yaml
Normal file
|
@ -0,0 +1,12 @@
|
|||
default_hour: 9
|
||||
default_minute: 0
|
||||
editor: vim -f -c 'setf markdown'
|
||||
encrypt: false
|
||||
highlight: true
|
||||
journals:
|
||||
default: features/journals/simple.journal
|
||||
linewrap: 80
|
||||
tagsymbols: "@"
|
||||
template: false
|
||||
timeformat: "%Y-%m-%d %H:%M"
|
||||
indent_character: "|"
|
|
@ -85,6 +85,7 @@ def open_editor_and_enter(context, text=""):
|
|||
text = text or context.text or ""
|
||||
|
||||
def _mock_editor_function(command):
|
||||
context.editor_command = command
|
||||
tmpfile = command[-1]
|
||||
with open(tmpfile, "w+") as f:
|
||||
f.write(text)
|
||||
|
@ -92,7 +93,17 @@ def open_editor_and_enter(context, text=""):
|
|||
return tmpfile
|
||||
|
||||
with patch("subprocess.call", side_effect=_mock_editor_function):
|
||||
run(context, "jrnl")
|
||||
context.execute_steps('when we run "jrnl"')
|
||||
|
||||
|
||||
@then("the editor should have been called with {num} arguments")
|
||||
def count_editor_args(context, num):
|
||||
assert len(context.editor_command) == int(num)
|
||||
|
||||
|
||||
@then('the editor arguments should contain "{arg}"')
|
||||
def contains_editor_arg(context, arg):
|
||||
assert arg in context.editor_command
|
||||
|
||||
|
||||
def _mock_getpass(inputs):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue