Sha256: 9dfce10532df708dfe943386709a22ae5c4819e44b1c0013944ef1e24b0b1795

Contents?: true

Size: 1020 Bytes

Versions: 7

Compression:

Stored size: 1020 Bytes

Contents

require "spec_helper"

describe Torasup do
  describe "#prefixes" do
    let(:prefixes) { described_class.prefixes }

    context "metadata" do
      it "should include the correct min, max and pattern values" do
        with_operators do |_number_parts, assertions|
          prefix = assertions["country_code"].to_s + assertions["area_code"].to_s + assertions["prefix"].to_s
          prefix_metadata = prefixes[prefix]
          local_number = assertions["local_number"]

          if subscriber_number_min = prefix_metadata["subscriber_number_min"]
            expect(local_number.to_i).to be >= subscriber_number_min
          end

          if subscriber_number_max = prefix_metadata["subscriber_number_max"]
            expect(local_number.to_i).to be <= subscriber_number_max
          end

          if subscriber_number_pattern = prefix_metadata["subscriber_number_pattern"]
            expect(local_number).to match(Regexp.new(subscriber_number_pattern))
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
torasup-0.3.3 spec/torasup_spec.rb
torasup-0.3.2 spec/torasup_spec.rb
torasup-0.3.1 spec/torasup_spec.rb
torasup-0.3.0 spec/torasup_spec.rb
torasup-0.2.3 spec/torasup_spec.rb
torasup-0.2.2 spec/torasup_spec.rb
torasup-0.2.1 spec/torasup_spec.rb