Sha256: fe15729cb20cd62da78b2a50c9acb91c169b8c7bac588079e99ae57229e7da3c

Contents?: true

Size: 1.26 KB

Versions: 6

Compression:

Stored size: 1.26 KB

Contents

require 'spec_helper'

describe ValidatesTelephone::Regex do
  context "#br" do
    context "with a valid number" do
      it "should return true" do
        ValidatesTelephone::Regex.br("(11)1111-1111").should be_true
      end
    end

    context "with an invalid number" do
      it "should return false" do
        ValidatesTelephone::Regex.br("11111111").should be_false
      end
    end
  end

  context "#usa" do
    context "with a valid number" do
      it "should return true" do
        ValidatesTelephone::Regex.usa("(111)111-1111").should == be_true
      end
    end

    context "with an invalid number" do
      it "should return false" do
        ValidatesTelephone::Regex.usa("11111111").should be_false
      end
    end
  end

  context "#any" do
    context "with a valid number from United States" do
      it "should return true" do
        ValidatesTelephone::Regex.any("(111)111-1111").should == be_true
      end
    end

    context "with a valid number from Brazil" do
      it "should return true" do
        ValidatesTelephone::Regex.any("(11)1111-1111").should == be_true
      end
    end

    context "with an invalid number" do
      it "should return nil" do
        ValidatesTelephone::Regex.any("11111111").should be_false
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

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