Sha256: e3aafa23f51ea52f66013cc0241ad057a3cf154a46c8a1dc411cd24f9c2d2945

Contents?: true

Size: 1.82 KB

Versions: 3

Compression:

Stored size: 1.82 KB

Contents

RSpec.describe H3 do
  include_context "constants"

  describe ".num_hexagons" do
    let(:resolution) { 2 }
    let(:result) { 5882 }

    subject(:num_hexagons) { H3.num_hexagons(resolution) }

    it { is_expected.to eq(result) }

    context "when given an invalid resolution" do
      let(:resolution) { too_long_number }
      let(:result) { false }

      it "returns the expected result" do
        expect { num_hexagons }.to raise_error(ArgumentError)
      end
    end
  end

  describe ".degs_to_rads" do
    let(:degs) { 100 }
    let(:result) { 1.7453292519943295 }

    subject(:degs_to_rads) { H3.degs_to_rads(degs) }

    it { is_expected.to eq(result) }
  end

  describe ".rads_to_degs" do
    let(:rads) { 1.7453292519943295 }
    let(:result) { 100 }

    subject(:rads_to_degs) { H3.rads_to_degs(rads) }

    it { is_expected.to eq(result) }
  end

  describe ".hex_area_km2" do
    let(:resolution) { 2 }
    let(:result) { 86745.85403 }

    subject(:hex_area_km2) { H3.hex_area_km2(resolution) }

    it { is_expected.to eq(result) }
  end

  describe ".hex_area_m2" do
    let(:resolution) { 2 }
    let(:result) { 86745854035.0 }

    subject(:hex_area_m2) { H3.hex_area_m2(resolution) }

    it { is_expected.to eq(result) }
  end

  describe ".edge_length_km" do
    let(:resolution) { 2 }
    let(:result) { 158.2446558 }

    subject(:edge_length_km) { H3.edge_length_km(resolution) }

    it { is_expected.to eq(result) }
  end
      
  describe ".edge_length_m" do
    let(:resolution) { 2 }
    let(:result) { 158244.6558 }

    subject(:edge_length_m) { H3.edge_length_m(resolution) }

    it { is_expected.to eq(result) }
  end

  describe ".res_0_indexes" do
    let(:count) { 122 }
    subject(:res_0_indexes) { H3.res_0_indexes }

    it "has 122 base cells" do
      expect(res_0_indexes.count).to eq(count)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
h3-3.5.0 spec/miscellaneous_spec.rb
h3-3.4.4 spec/miscellaneous_spec.rb
h3-3.4.0 spec/miscellaneous_spec.rb