Sha256: d3fa17d94ec39d233102ced6334bcb83944068893472dccc08e6ba7a617cfe7d

Contents?: true

Size: 1019 Bytes

Versions: 3

Compression:

Stored size: 1019 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

3 entries across 3 versions & 1 rubygems

Version Path
torasup-0.2.0 spec/torasup_spec.rb
torasup-0.1.2 spec/torasup_spec.rb
torasup-0.1.1 spec/torasup_spec.rb