diff --git a/features/data/journals/simple.journal b/features/data/journals/simple.journal new file mode 100644 index 00000000..8336068e --- /dev/null +++ b/features/data/journals/simple.journal @@ -0,0 +1,5 @@ +[2013-06-09 15:39] My first entry. +Everything is alright + +[2013-06-10 15:40] Life is good. +But I'm better. diff --git a/features/exporting.feature b/features/exporting.feature index 003801a3..3d6c2607 100644 --- a/features/exporting.feature +++ b/features/exporting.feature @@ -20,3 +20,9 @@ Feature: Exporting a Journal and "tags" in the json output should contain "@journal" and "tags" in the json output should not contain "@dan" + Scenario: Exporting dayone to json + Given we use the config "dayone.yaml" + When we run "jrnl --export json" + Then we should get no error + and the output should be parsable as json + and the json output should contain entries.0.uuid = "4BB1F46946AD439996C9B59DE7C4DDC1" diff --git a/features/steps/core.py b/features/steps/core.py index e7711e9a..7997f8e7 100644 --- a/features/steps/core.py +++ b/features/steps/core.py @@ -126,6 +126,22 @@ def check_output_field_key(context, field, key): assert key in out_json[field] +@then('the json output should contain {path} = "{value}"') +def check_json_output_path(context, path, value): + """ E.g. + the json output should contain entries.0.title = "hello" + """ + out = context.stdout_capture.getvalue() + struct = json.loads(out) + + for node in path.split('.'): + try: + struct = struct[int(node)] + except ValueError: + struct = struct[node] + assert struct == value, struct + + @then('the output should be') @then('the output should be "{text}"') def check_output(context, text=None):