Skip to content

Commit

Permalink
Merge pull request #13 from PugglePay/master
Browse files Browse the repository at this point in the history
Do not pollute the global namespace with a Country class. Only require'ing iso3166 (part of countries gem).
  • Loading branch information
Joost Hietbrink committed Dec 18, 2012
2 parents 530f071 + 19c68e7 commit 873e598
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/phony_rails.rb
@@ -1,5 +1,5 @@
require 'phony' require 'phony'
require 'countries' require 'iso3166'
require 'phony_rails/string_extensions' require 'phony_rails/string_extensions'
require 'validators/phony_validator' require 'validators/phony_validator'
require 'phony_rails/version' require 'phony_rails/version'
Expand Down
12 changes: 8 additions & 4 deletions spec/lib/phony_rails_spec.rb
@@ -1,6 +1,10 @@
require 'spec_helper' require 'spec_helper'
describe PhonyRails do describe PhonyRails do


it "should not pollute the global namespace with a Country class" do
should_not be_const_defined "Country"
end

describe 'String extensions' do describe 'String extensions' do
it "should phony_format a String" do it "should phony_format a String" do
"31101234123".phony_formatted(:format => :international, :spaces => '-').should eql('+31-10-1234123') "31101234123".phony_formatted(:format => :international, :spaces => '-').should eql('+31-10-1234123')
Expand Down Expand Up @@ -124,14 +128,14 @@
home.normalized_phone1_method(:country_code => 'NL').should eql('31308612906') home.normalized_phone1_method(:country_code => 'NL').should eql('31308612906')
end end


it "should use last passed options" do it "should use last passed options" do
home = Home.new(:phone1_method => "(030) 8 61 29 06") home = Home.new(:phone1_method => "(030) 8 61 29 06")
home.normalized_phone1_method(:country_code => 'NL').should eql('31308612906') home.normalized_phone1_method(:country_code => 'NL').should eql('31308612906')
home.normalized_phone1_method(:country_code => 'DE').should eql('49308612906') home.normalized_phone1_method(:country_code => 'DE').should eql('49308612906')
home.normalized_phone1_method(:country_code => nil).should eql('49308612906') home.normalized_phone1_method(:country_code => nil).should eql('49308612906')
end end


it "should use last object method" do it "should use last object method" do
home = Home.new(:phone1_method => "(030) 8 61 29 06") home = Home.new(:phone1_method => "(030) 8 61 29 06")
home.country_code = 'NL' home.country_code = 'NL'
home.normalized_phone1_method.should eql('31308612906') home.normalized_phone1_method.should eql('31308612906')
Expand All @@ -154,6 +158,6 @@
home = Home.new(:phone_number => "+31-(0)10-1234123") home = Home.new(:phone_number => "+31-(0)10-1234123")
home.valid?.should be_true home.valid?.should be_true
home.phone_number_as_normalized.should eql('31101234123') home.phone_number_as_normalized.should eql('31101234123')
end end
end end
end end

0 comments on commit 873e598

Please sign in to comment.