Sha256: 628073520acd3866fdd0a8e6108bdf15a3b33da0dfcea358eb0bfbd4c9bb33a5

Contents?: true

Size: 1.04 KB

Versions: 6

Compression:

Stored size: 1.04 KB

Contents

require "test_helper"

class HarvestUnitTest < Minitest::Test
  def setup
    get_client
    get_facility

    stub_request(:get, "http://localhost:3000/api/v3/facilities/#{@facility.id}/harvest_units")
      .to_return(body: {data: [{id: '1', type: 'harvest_units', attributes: {id: 1, name: 'pound', weight: 1}}, {id: '2', type: 'harvest_units', attributes: {id: 2, name: 'kilogram', weight: 2.2}}]}.to_json)

    stub_request(:get, "http://localhost:3000/api/v3/facilities/#{@facility.id}/harvest_units/2")
      .to_return(body: {data: {id: '2', type: 'harvest_units', attributes: {id: 2, name: 'kilogram', weight: 2.2}}}.to_json)
  end

  def test_finding_all_harvest_units
    harvest_units = ArtemisApi::HarvestUnit.find_all(facility_id: @facility.id, client: @client)
    assert_equal 2, harvest_units.count
  end

  def test_finding_a_specific_harvest_unit
    harvest_unit = ArtemisApi::HarvestUnit.find(id: 2, facility_id: @facility.id, client: @client)
    assert_equal 'kilogram', harvest_unit.name
    assert_equal 2.2, harvest_unit.weight
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
artemis_api-0.7.5 test/harvest_unit_test.rb
artemis_api-0.7.4 test/harvest_unit_test.rb
artemis_api-0.5.1 test/harvest_unit_test.rb
artemis_api-0.4.0 test/harvest_unit_test.rb
artemis_api-0.3.0 test/harvest_unit_test.rb
artemis_api-0.2.1 test/harvest_unit_test.rb