Sha256: 2ea5f7ca944c84a8e51df8d017885696f4975e02f7eb8dd48989b152a4a30f37

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

# encoding: UTF-8
require 'spec_helper'

describe Correios::SRO::Rastreador do
  describe ".new" do
    context "creates with default value of" do
      before(:each) { @sro = Correios::SRO::Rastreador.new }

      { :tipo => :lista,
        :resultado => :ultimo,
        :objetos => []
      }.each do |attr, value|
        it attr do
          @sro.send(attr).should == value
        end
      end
    end

    { :usuario => "USUARIO",
      :senha => "SENHA",
      :tipo => :intervalo,
      :resultado => :todos
    }.each do |attr, value|
      context "when #{attr} is supplied" do
        it "sets #{attr}" do
          sro = Correios::SRO::Rastreador.new(attr => value)
          sro.send(attr).should == value
        end
      end

      context "when #{attr} is supplied in a block" do
        it "sets #{attr}" do
          sro = Correios::SRO::Rastreador.new { |f| f.send("#{attr}=", value) }
          sro.send(attr).should == value
        end
      end
    end
  end

  describe "#consultar" do
    before(:each) { @sro = Correios::SRO::Rastreador.new :usuario => "USUARIO", :senha => "SENHA" }

    it "sets objetos" do
      @sro.consultar("SQ458226057B", "RA132678652BR")
      @sro.objetos.size.should == 2
      @sro.objetos.first.should == "SQ458226057B"
      @sro.objetos.last.should == "RA132678652BR"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
correios-sro-xml-0.0.1 spec/correios/sro/rastreador_spec.rb