Sha256: 64e49f27113eefd3c75a2c3eb4b0bd0f4db1067ff81d8ca08adf83834ab6615e
Contents?: true
Size: 1.45 KB
Versions: 23
Compression:
Stored size: 1.45 KB
Contents
require File.expand_path('../test_helper', __FILE__) class TestOrganization < Minitest::Test FIXTURE = API_FIXTURES.fetch("organization") FIXTURE_FOR_LIST = API_FIXTURES.fetch("organizations") def test_retrieve() stub_request(:get, /organizations/). to_return(status: 200, body: FIXTURE.to_json) organization = MyJohnDeere::Organization.retrieve(default_access_token, FIXTURE[:id]) assert_equal "1234", organization.id assert_equal "Smith Farms", organization.name assert_equal "customer", organization.type assert_equal true, organization.member assert_equal FIXTURE["links"].length, organization.links.length assert organization.access_token end def test_list() stub_request(:get, /organizations;start=0;count=1/). to_return(status: 200, body: FIXTURE_FOR_LIST.to_json) organizations = MyJohnDeere::Organization.list(default_access_token, count: 1) assert_equal 1, organizations.data.length assert_equal MyJohnDeere::Organization, organizations.data[0].class assert_equal 2, organizations.links.length end def test_fields() organization = MyJohnDeere::Organization.new(FIXTURE, default_access_token) stub_request(:get, /organizations\/#{organization.id}\/fields/). to_return(status: 200, body: API_FIXTURES["fields"].to_json) fields = organization.fields assert_equal MyJohnDeere::ListObject, fields.class assert_equal MyJohnDeere::Field, fields.data[0].class end end
Version data entries
23 entries across 23 versions & 1 rubygems