test/test_rest_methods.rb in myjohndeere-0.0.11 vs test/test_rest_methods.rb in myjohndeere-0.1.0

- old
+ new

@@ -23,10 +23,24 @@ assert_raises MyJohnDeere::UnsupportedRequestError do MyJohnDeere::Organization.delete(default_access_token, "foobar") end end + def test_deleted_object_with_etag + etag_val = "something" + new_etag = "something2" + stub_request(:get, /organizations\Z/). + with(headers: {MyJohnDeere::ETAG_HEADER_KEY => etag_val}). + to_return(status: 200, body: API_FIXTURES["deleted_organization"].to_json(), + headers: {MyJohnDeere::ETAG_HEADER_KEY=>new_etag}) + + organizations = MyJohnDeere::Organization.list(default_access_token, etag: etag_val) + + assert organizations.data.first.deleted + assert_equal new_etag, organizations.etag + end + def test_list_with_etag stub_request(:get, /organizations/). with(headers: {MyJohnDeere::ETAG_HEADER_KEY => ""}). to_return(status: 200, body: LIST_FIXTURE.to_json(), headers: {MyJohnDeere::ETAG_HEADER_KEY=>"something"}) @@ -47,11 +61,12 @@ MyJohnDeere::Organization.build_resource_base_path!(resource_path, {}) end end def test_list_with_body - stub_request(:get, /organizations;start=0;count=1/). - with(query: {embed: "boundaries"}). + stub_request(:get, /organizations/). + with(query: {embed: "boundaries"}, + headers: {MyJohnDeere::ETAG_HEADER_KEY=>""}). to_return(status: 200, body: LIST_FIXTURE.to_json()) organizations = MyJohnDeere::Organization.list(default_access_token, count: 1, etag: "", body: {embed: "boundaries"}) assert_equal({:embed=>"boundaries"}, organizations.options[:body]) end end \ No newline at end of file