Sha256: 42e7396e0ccbb343a32e53d099184983ca6fa20bbc4a05420d4f7d011a83c9ec

Contents?: true

Size: 1.8 KB

Versions: 10

Compression:

Stored size: 1.8 KB

Contents

require "spec_helper"

describe PagSeguro::Sender do
  context "instance" do
    before { @sender = PagSeguro::Sender.new }
    
    it "should have an email accessor" do
      @sender.should have_attribute_accessor(:email)
    end
    
    it "should have a name accessor" do
      @sender.should have_attribute_accessor(:name)
    end

    it "should have a phone_ddd accessor" do
      @sender.should have_attribute_accessor(:phone_ddd)
    end

    it "should have a phone_number" do
      @sender.should have_attribute_accessor(:phone_number)
    end
    
    it "should be able to initialize with all attributes" do
      sender = PagSeguro::Sender.new(name: "Stefano Diem Benatti", email: "stefano@heavenstudio.com.br", phone_ddd: "11", phone_number: "93430994")
      sender.name.should == "Stefano Diem Benatti"
      sender.email.should == "stefano@heavenstudio.com.br"
      sender.phone_ddd.should == "11"
      sender.phone_number.should == "93430994"
    end
    
    it "should tell valid e-mail appart" do
      @sender.email = "nothing"
      @sender.should_not be_a_valid_email
      @sender.email = ("a" * 50) + "waytoolongemail@mail.com"
      @sender.should_not be_a_valid_email
      @sender.email = "stefano@heavenstudio.com.br"
      @sender.should be_a_valid_email
    end
    
    it "should not show invalid e-mail" do
      @sender.email = "nothing"
      @sender.email.should be_nil
    end
    
    it "should crop the name if it is too big" do
      @sender.name = "a" * 50 + "b" * 10
      @sender.name.should == "a" * 50
    end
    
    it "should not show invalid phone ddd's" do
      @sender.phone_ddd = "111"
      @sender.phone_ddd.should be_nil
    end
    
    it "should not show invalid phone number" do
      @sender.phone_number = "1234567"
      @sender.phone_number.should be_nil
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
pag_seguro-0.2.0 spec/pag_seguro/sender_spec.rb
pag_seguro-0.1.9 spec/pag_seguro/sender_spec.rb
pag_seguro-0.1.8 spec/pag_seguro/sender_spec.rb
pag_seguro-0.1.7 spec/pag_seguro/sender_spec.rb
pag_seguro-0.1.6 spec/pag_seguro/sender_spec.rb
pag_seguro-0.1.4 spec/pag_seguro/sender_spec.rb
pag_seguro-0.1.3 spec/pag_seguro/sender_spec.rb
pag_seguro-0.1.2 spec/pag_seguro/sender_spec.rb
pag_seguro-0.1.1 spec/pag_seguro/sender_spec.rb
pag_seguro-0.1.0 spec/pag_seguro/sender_spec.rb