Sha256: 84a1032feb44f43bca2b9fb62bf19278331815129f0c435ca45fd3fef6f80cb8

Contents?: true

Size: 1.24 KB

Versions: 6

Compression:

Stored size: 1.24 KB

Contents

require 'spec_helper'

describe ValidatesTelephone::Formatter do
  context "#br" do
    context "with a nil value" do
      it "should return nil" do
        ValidatesTelephone::Formatter.br(nil).should be_nil
      end
    end

    context "with a valid number" do
      it "should return it formatted" do
        ValidatesTelephone::Formatter.br("1111111111").should == "(11)1111-1111"
      end
    end

    context "with an invalid number" do
      it "should return as it was" do
        ValidatesTelephone::Formatter.br("11111111").should == "11111111"
      end
    end
  end

  context "#usa" do
    context "with a nil value" do
      it "should return nil" do
        ValidatesTelephone::Formatter.usa(nil).should be_nil
      end
    end

    context "with a valid number" do
      it "should return it formatted" do
        ValidatesTelephone::Formatter.usa("1111111111").should == "(111)111-1111"
      end
    end

    context "with an invalid number" do
      it "should return as it was" do
        ValidatesTelephone::Formatter.usa("11111111").should == "11111111"
      end
    end
  end

  context "#any" do
    it "should always return the number as it was" do
      ValidatesTelephone::Formatter.any("11111").should == "11111"
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
validates_telephone-2.0.2 spec/validates_telephone/formatter_spec.rb
validates_telephone-2.0.1 spec/validates_telephone/formatter_spec.rb
validates_telephone-2.0.0 spec/validates_telephone/formatter_spec.rb
validates_telephone-1.1.0 spec/validates_telephone/formatter_spec.rb
validates_telephone-1.0.1 spec/validates_telephone/formatter_spec.rb
validates_telephone-1.0.0 spec/validates_telephone/formatter_spec.rb