Created
February 18, 2016 11:10
-
-
Save craigp/85b4534a1e2fade29d64 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test "updates a label", %{ | |
label: label, | |
label_name: label_name, | |
access_token_rec: access_token_rec, | |
expected_result: expected_result, | |
bypass: bypass, | |
label_id: label_id | |
} do | |
Bypass.expect bypass, fn conn -> | |
{:ok, body, _} = Plug.Conn.read_body(conn) | |
{:ok, body_params} = body |> Poison.decode | |
assert body_params == %{ | |
"id" => label_id, | |
"name" => label_name, | |
"labelListVisibility" => "labelShow", | |
"messageListVisibility" => "show" | |
} | |
assert "/gmail/v1/users/me/labels/#{label_id}" == conn.request_path | |
assert "" == conn.query_string | |
assert "PUT" == conn.method | |
{:ok, json} = Poison.encode(label) | |
Plug.Conn.resp(conn, 200, json) | |
end | |
with_mock Gmail.OAuth2, [get_config: fn -> access_token_rec end] do | |
{:ok, label} = Gmail.Label.update(expected_result) | |
assert expected_result == label | |
assert called Gmail.OAuth2.get_config | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment