Sha256: 2784f1a31175b0d691f9fa1b76bf9c72a37618a3c9361ed8620ef694262dc129
Contents?: true
Size: 1.49 KB
Versions: 6
Compression:
Stored size: 1.49 KB
Contents
require "test_helper" class FacilityTest < Minitest::Test def setup get_client stub_request(:get, 'http://localhost:3000/api/v3/facilities') .to_return(body: {data: [{id: '1', type: 'facilities', attributes: {id: 1, name: 'Sky Fresh'}}, {id: '2', type: 'facilities', attributes: {id: 2, name: 'Rare Dankness'}}]}.to_json) end def test_finding_all_facilities facilities = ArtemisApi::Facility.find_all(client: @client) assert_equal 2, facilities.count end def test_finding_all_facilities_through_client facilities = @client.facilities assert_equal 2, facilities.count end def test_finding_a_specific_facility stub_request(:get, 'http://localhost:3000/api/v3/facilities/2') .to_return(body: {data: {id: '2', type: 'facilities', attributes: {id: 2, name: 'Rare Dankness'}}}.to_json) facility = ArtemisApi::Facility.find(id: 2, client: @client) assert_equal 'Rare Dankness', facility.name end def test_finding_a_specific_facility_through_client stub_request(:get, 'http://localhost:3000/api/v3/facilities/2') .to_return(body: {data: {id: '2', type: 'facilities', attributes: {id: 2, name: 'Rare Dankness'}}}.to_json) facility = @client.facility(2) assert_equal 'Rare Dankness', facility.name end def test_finding_a_specific_facility_thats_already_in_memory ArtemisApi::Facility.find_all(client: @client) facility = ArtemisApi::Facility.find(id: 2, client: @client) assert_equal 'Rare Dankness', facility.name end end
Version data entries
6 entries across 6 versions & 1 rubygems