Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Using :valor instead of :value #8

Merged
merged 1 commit into from

2 participants

@rinaldifonseca

No description provided.

@jvrmaia jvrmaia merged commit 0cee70e into moiplabs:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 25, 2011
  1. @rinaldifonseca
This page is out of date. Refresh to see the latest.
Showing with 55 additions and 55 deletions.
  1. +55 −55 spec/moip_spec.rb
View
110 spec/moip_spec.rb
@@ -23,17 +23,17 @@
:cep => "70100-000",
:tel_fixo => "(61)3211-1221" }
- @billet_without_razao = { :value => "8.90", :id_proprio => id,
+ @billet_without_razao = { :valor => "8.90", :id_proprio => id,
:forma => "BoletoBancario", :pagador => @pagador}
- @billet = { :value => "8.90", :id_proprio => id,
+ @billet = { :valor => "8.90", :id_proprio => id,
:forma => "BoletoBancario", :pagador => @pagador ,
:razao=> "Pagamento" }
- @debit = { :value => "8.90", :id_proprio => id, :forma => "DebitoBancario",
+ @debit = { :valor => "8.90", :id_proprio => id, :forma => "DebitoBancario",
:instituicao => "BancoDoBrasil", :pagador => @pagador,
:razao => "Pagamento"}
- @credit = { :value => "8.90", :id_proprio => id, :forma => "CartaoCredito",
+ @credit = { :valor => "8.90", :id_proprio => id, :forma => "CartaoCredito",
:instituicao => "AmericanExpress",:numero => "345678901234564",
:expiracao => "08/11", :codigo_seguranca => "1234",
:nome => "João Silva", :identidade => "134.277.017.00",
@@ -54,19 +54,19 @@
config.token = nil
config.key = 'key'
end
-
+
MoIP::Client # for autoload
lambda { MoIP::Client.checkout(@billet) }.should raise_error(MoIP::MissingTokenError)
end
it "should raise a missing key error when key is nil" do
-
+
MoIP.setup do |config|
config.uri = 'https://desenvolvedor.moip.com.br/sandbox'
config.token = 'token'
config.key = nil
end
-
+
MoIP::Client # for autoload
lambda { MoIP::Client.checkout(@billet) }.should raise_error(MoIP::MissingKeyError)
end
@@ -79,24 +79,24 @@
config.token = ''
config.key = 'key'
end
-
+
MoIP::Client # for autoload
lambda { MoIP::Client.checkout(@billet) }.should raise_error(MoIP::MissingTokenError)
end
it "should raise a missing key error when key is empty" do
-
+
MoIP.setup do |config|
config.uri = 'https://desenvolvedor.moip.com.br/sandbox'
config.token = 'token'
config.key = ''
end
-
+
MoIP::Client # for autoload
lambda { MoIP::Client.checkout(@billet) }.should raise_error(MoIP::MissingKeyError)
end
end
-
+
context "checkout" do
before(:each) do
MoIP.setup do |config|
@@ -113,14 +113,14 @@
}
})
end
-
+
it "with old api should be deprecated" do
deprecations = collect_deprecations{ MoIP.checkout(@billet) }
-
+
deprecations.should_not be_empty
deprecations.any? {|w| w =~ /MoIP.checkout has been deprecated/ }.should be_true
end
-
+
context "when it is a billet checkout" do
before(:each) do
MoIP.setup do |config|
@@ -131,16 +131,16 @@
end
it "should raise an exception when razao parameter is not passed" do
error = "É necessário informar a razão do pagamento"
-
+
lambda { MoIP::Client.checkout(@billet_without_razao) }.should raise_error(MoIP::MissingPaymentTypeError,error)
end
-
+
it "should have status 'Sucesso'" do
response = MoIP::Client.checkout(@billet)
response["Status"].should == "Sucesso"
end
end
-
+
context "when it is a debit checkout" do
before(:each) do
MoIP.setup do |config|
@@ -153,14 +153,14 @@
response = MoIP::Client.checkout(@debit)
response["Status"].should == "Sucesso"
end
-
+
it "should have status 'Falha' when a instituition is not passed as argument" do
- @incorrect_debit = { :value => "37.90", :id_proprio => id,
+ @incorrect_debit = { :valor => "37.90", :id_proprio => id,
:forma => "DebitoBancario", :pagador => @pagador,
:razao => "Pagamento"}
-
+
error = "Pagamento direto não é possível com a instituição de pagamento enviada"
-
+
MoIP::Client.stub!(:post).and_return("ns1:EnviarInstrucaoUnicaResponse"=>
{ "Resposta"=>
{
@@ -172,19 +172,19 @@
lambda { MoIP::Client.checkout(@incorrect_debit) }.should
raise_error(MoIP::WebServerResponseError, error)
end
-
+
it "should raise an exception if payer informations were not passed" do
- @incorrect_debit = { :value => "37.90", :id_proprio => id,
+ @incorrect_debit = { :valor => "37.90", :id_proprio => id,
:forma => "DebitoBancario",
:instituicao => "BancoDoBrasil",
:razao => "Pagamento"
}
-
+
lambda { MoIP::Client.checkout(@incorrect_debit) }.should
raise_error(MoIP::MissingPayerError, "É obrigatório passar as informações do pagador")
end
end
-
+
context "when it is a credit card checkout" do
before(:each) do
MoIP.setup do |config|
@@ -197,13 +197,13 @@
response = MoIP::Client.checkout(@credit)
response["Status"].should == "Sucesso"
end
-
+
it "should have status 'Falha' when the card informations were not passed as argument" do
- @incorrect_credit = { :value => "8.90", :id_proprio => id,
+ @incorrect_credit = { :valor => "8.90", :id_proprio => id,
:forma => "CartaoCredito", :pagador => @pagador,
:razao => "Pagamento"
}
-
+
error = "Pagamento direto não é possível com a instituição de pagamento enviada"
MoIP::Client.stub!(:post).and_return("ns1:EnviarInstrucaoUnicaResponse"=>
{
@@ -213,13 +213,13 @@
"Erro"=>error
}
})
-
+
error = "Pagamento direto não é possível com a instituição de pagamento enviada"
lambda { MoIP::Client.checkout(@incorrect_credit) }.should
raise_error(MoIP::WebServerResponseError, error)
end
end
-
+
context "in error scenario" do
before(:each) do
MoIP.setup do |config|
@@ -233,7 +233,7 @@
lambda { MoIP::Client.checkout(@billet) }.should
raise_error(StandardError,"Ocorreu um erro ao chamar o webservice")
end
-
+
it "should raise an exception if status is fail" do
MoIP::Client.stub!(:post).and_return("ns1:EnviarInstrucaoUnicaResponse"=>
{ "Resposta"=>
@@ -241,16 +241,16 @@
"Erro"=>"O status da resposta é Falha"
}
})
-
+
lambda { MoIP::Client.checkout(@billet) }.should raise_error(StandardError, "O status da resposta é Falha")
end
end
end
-
+
context "query a transaction token" do
-
+
before(:each) do
-
+
MoIP.setup do |config|
config.uri = 'https://desenvolvedor.moip.com.br/sandbox'
config.token = 'token'
@@ -263,19 +263,19 @@
}
})
end
-
+
it "with old api should be deprecated" do
deprecations = collect_deprecations{ MoIP.query(token) }
-
+
deprecations.should_not be_empty
deprecations.any? {|w| w =~ /MoIP.query has been deprecated/ }.should be_true
end
-
+
it "should retrieve the transaction" do
response = MoIP::Client.query(token)
response["Status"].should == "Sucesso"
end
-
+
context "in a error scenario" do
before(:each) do
MoIP.setup do |config|
@@ -297,7 +297,7 @@
end
end
end
-
+
context "build the MoIP URL" do
before(:each) do
MoIP.setup do |config|
@@ -308,37 +308,37 @@
end
it "with old api should be deprecated" do
deprecations = collect_deprecations{ MoIP.moip_page(token) }
-
+
deprecations.should_not be_empty
deprecations.any? {|w| w =~ /MoIP.moip_page has been deprecated/ }.should be_true
end
-
+
it "should build the correct URL" do
page = "https://desenvolvedor.moip.com.br/sandbox/Instrucao.do?token=#{token}"
MoIP::Client.moip_page(token).should == page
end
-
+
it "should raise an error if the token is not informed" do
error = "É necessário informar um token para retornar os dados da transação"
lambda { MoIP::Client.moip_page("").should
raise_error(ArgumentError, error) }
end
-
+
it "should raise an error if nil is passed as the token" do
error = "É necessário informar um token para retornar os dados da transação"
lambda { MoIP::Client.moip_page(nil).should
raise_error(ArgumentError, error) }
end
-
+
it "should raise a missing token error if nil is passed as the token" do
lambda { MoIP::Client.moip_page(nil).should raise_error(MissingTokenError) }
end
-
+
it "should raise a missing token error if an empty string is passed as the token" do
lambda { MoIP::Client.moip_page("").should raise_error(MissingTokenError) }
end
end
-
+
context "when receive notification" do
before(:each) do
MoIP.setup do |config|
@@ -351,23 +351,23 @@
"forma_pagamento" => "73", "tipo_pagamento" => "BoletoBancario",
"email_consumidor" => "presidente@planalto.gov.br" }
end
-
+
it "with old api should be deprecated" do
deprecations = collect_deprecations{ MoIP.notification(@param) }
-
+
deprecations.should_not be_empty
deprecations.any? {|w| w =~ /MoIP.notification has been deprecated/ }.should be_true
end
-
+
it "should return a hash with the params extracted from NASP" do
response = { :transaction_id => "Pag62", :amount => "8.90",
:status => "printed", :code => "001",
:payment_type => "BoletoBancario",
:email => "presidente@planalto.gov.br" }
-
+
MoIP::Client.notification(@params).should == response
end
-
+
it "should return valid status based on status code" do
MoIP::STATUS[1].should == "authorized"
MoIP::STATUS[2].should == "started"
@@ -377,15 +377,15 @@
MoIP::STATUS[6].should == "analysing"
end
end
-
+
def id
"transaction_" + Digest::SHA1.hexdigest([Time.now, rand].join)
end
-
+
def token
"T2X0Q1N021E0B2S9U1P0V3Y0G1F570Y2P4M0P000M0Z0F0J0G0U4N6C7W5T9"
end
-
+
def collect_deprecations
old_behavior = ActiveSupport::Deprecation.behavior
deprecations = []
Something went wrong with that request. Please try again.