torasup 0.0.14 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b7144467b57e2eeafdba6c249cb437af5c6343c2
4
- data.tar.gz: cc55cdf7563d65b4d12976e2e0e1a766ace0cb7c
3
+ metadata.gz: 02c09491e5cda23554f00cc013fded14e8d838c6
4
+ data.tar.gz: a6ff34c7db89102b4a78c409becdeff38d7551e0
5
5
  SHA512:
6
- metadata.gz: 0e95a24e60abc5a90b55664e2d07a54fff4c629a7ca9bc7111d7deace3b51c5179ffc15e34f2c4bd076384745cc74e885ca28da5e11958788197ffbcff843f73
7
- data.tar.gz: 8a5ea60ec29983fb47037ccc48eea81466644012ca60f0a7d9b0718e42f8c23536dc0de7f03382accd9c9c86455e58d4b3c9a3f58b34e35009dd02bdd63aa7d6
6
+ metadata.gz: 20ab556f408911e118d895335f3bf2759ca688a42972152f7ba52c834b34dd43d2b885845e36d260f7616cce3d7528a98d27f376889d3ab506a75bd9cfcc9bd0
7
+ data.tar.gz: 54263d8a2b91be632769031b7ac8d5f937c4db7751d4671f8b6466b527f0124f893f5837f51da0cbc2813ca8ad6979341fb1855a0d40c3ae463cd7a31103ce3e
@@ -1,3 +1,3 @@
1
1
  module Torasup
2
- VERSION = "0.0.14"
2
+ VERSION = "0.0.15"
3
3
  end
data/lib/torasup.rb CHANGED
@@ -23,7 +23,7 @@ module Torasup
23
23
  @international_dialing_codes = {}
24
24
  ISO3166::Country.all.each do |country|
25
25
  dialing_code = country.country_code
26
- @international_dialing_codes[dialing_code] = country.alpha2 if !@international_dialing_codes[dialing_code] && !configuration.default_countries.include?(country.alpha2)
26
+ @international_dialing_codes[dialing_code] = country.alpha2 if !@international_dialing_codes[dialing_code] || configuration.default_countries.include?(country.alpha2)
27
27
  end
28
28
  end
29
29
 
@@ -32,19 +32,32 @@ describe Torasup do
32
32
  end
33
33
  end
34
34
 
35
- describe "#default_countries=('['US', 'AU']')" do
36
- before do
37
- allow(Torasup).to receive(:load_international_dialing_codes!)
38
- end
35
+ describe "#default_countries=(value)" do
36
+ let(:torasup_number) { Torasup::PhoneNumber.new("+1 415-234 5678") }
39
37
 
40
- it "should set the default countries and reload the data" do
41
- Torasup.configure do |config|
42
- expect(Torasup).to receive(:load_international_dialing_codes!)
43
- expect(config.default_countries).to eq(["US", "GB", "AU", "IT", "RU", "NO"])
44
- config.default_countries = ["US", "GB"]
45
- expect(config.default_countries).to eq(["US", "GB"])
38
+ context "configuring" do
39
+ before do
40
+ allow(Torasup).to receive(:load_international_dialing_codes!)
41
+ end
42
+
43
+ it "should set the default countries and reload the data" do
44
+ Torasup.configure do |config|
45
+ expect(Torasup).to receive(:load_international_dialing_codes!)
46
+ expect(config.default_countries).to eq(["US", "GB", "AU", "IT", "RU", "NO"])
47
+ config.default_countries = ["US", "GB"]
48
+ expect(config.default_countries).to eq(["US", "GB"])
49
+ end
46
50
  end
47
51
  end
52
+
53
+ context "by default" do
54
+ it { expect(torasup_number.country_id).to eq("us") }
55
+ end
56
+
57
+ context "overriding defaults" do
58
+ before { Torasup.configure { |config| config.default_countries = ["CA"] } }
59
+ it { expect(torasup_number.country_id).to eq("ca") }
60
+ end
48
61
  end
49
62
 
50
63
  describe "#custom_pstn_data_file=('path_to_yaml_file.yaml')" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: torasup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Wilkie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-26 00:00:00.000000000 Z
11
+ date: 2015-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: countries