Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not pollute the global namespace with a Country class #13

Merged
merged 1 commit into from
Dec 18, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/phony_rails.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'phony'
require 'countries'
require 'iso3166'
require 'phony_rails/string_extensions'
require 'validators/phony_validator'
require 'phony_rails/version'
Expand Down
12 changes: 8 additions & 4 deletions spec/lib/phony_rails_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
require 'spec_helper'
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
it "should phony_format a String" do
"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')
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.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 => nil).should eql('49308612906')
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.country_code = 'NL'
home.normalized_phone1_method.should eql('31308612906')
Expand All @@ -154,6 +158,6 @@
home = Home.new(:phone_number => "+31-(0)10-1234123")
home.valid?.should be_true
home.phone_number_as_normalized.should eql('31101234123')
end
end
end
end
end