diff options
Diffstat (limited to 'yarns/900-implements.yarn')
-rw-r--r-- | yarns/900-implements.yarn | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/yarns/900-implements.yarn b/yarns/900-implements.yarn new file mode 100644 index 0000000..7eb0c86 --- /dev/null +++ b/yarns/900-implements.yarn @@ -0,0 +1,69 @@ +# Scenario step implementations + +## Start and stop Muck + + IMPLEMENTS GIVEN a running Muck + start_muck() + + IMPLEMENTS WHEN Muck is restarted + stop_muck() + start_muck() + + IMPLEMENTS FINALLY Muck is stopped + stop_muck() + +## HTTP requests + + IMPLEMENTS WHEN user makes request POST /res with body (.*) + body = get_expanded_match() + POST('/res', {}, json.loads(body)) + + IMPLEMENTS WHEN user makes request GET /res with header "(\S+): (.+)" + header = get_expanded_match() + value = get_expanded_match() + GET('/res', {header:value}) + + IMPLEMENTS WHEN user makes request GET /search with body (.+) + body = json.loads(get_expanded_match()) + GET('/search', {}, body=body) + + IMPLEMENTS WHEN user makes request PUT /res with header "(\S+): (.+)" and header "(\S+): (.+)" and body (.+) + header1 = get_expanded_match() + value1 = get_expanded_match() + header2 = get_expanded_match() + value2 = get_expanded_match() + body = get_expanded_match() + headers = { + header1: value1, + header2: value2, + } + PUT('/res', headers, json.loads(body)) + + IMPLEMENTS WHEN user makes request DELETE /res with header "(\S+): (.+)" + header = get_expanded_match() + value = get_expanded_match() + DELETE('/res', {header:value}) + +## Checking HTTP responses + + IMPLEMENTS THEN status code is (\d+) + expected = int(get_expanded_match()) + assertEqual(V['status_code'], expected) + + IMPLEMENTS THEN remember resource id as (\S+) + name = get_next_match() + save_header('Muck-Id', name) + + IMPLEMENTS THEN remember resource revision as (\S+) + name = get_next_match() + save_header('Muck-Revision', name) + + IMPLEMENTS THEN response has header "(\S+): (.+)" + name = get_next_match() + expected = get_expanded_match() + assertEqual(get_header(name), expected) + + IMPLEMENTS THEN response body is (.+) + expected = get_expanded_match() + print 'expected:', expected + assertEqual(get_json_body(), json.loads(expected)) |