require 'spec_helper' require 'mercado_pago_rails/mercado_pago_response' describe MercadoPagoResponse do let(:successful_response) { MercadoPagoResponse.new(get_success_response) } describe "#success?" do context "when consulted if there was an error" do it "it returns false" do successful_response.success?.should be_true end end end describe "#redirect_url" do context "when consulted for the redirect url" it "it returns the correct url" do successful_response.redirect_url.should eq "http://checkout.url.com" end end def get_success_response { "response" => { "external_reference"=> "Reference_1234", "items"=> [{ "id"=> "Código", "title"=> "Título de lo que estás pagando", "description"=> "Descripción", "quantity"=> 1, "unit_price"=> 50.5, "currency_id"=> "Tipo de moneda", "picture_url"=> "https=>//www.mercadopago.com/org-img/MP3/home/logomp3.gif" }], "date_created"=> "2011-08-16T21=>28=>42.606-04=>00", "id"=> "identificador_de_la_preferencia", "collector_id"=> "tu_identificador_como_vendedor", "init_point"=> "http://checkout.url.com", "payer"=> { "email"=> "payer@email.com", "name"=> "payer-name", "surname"=> "payer-surname" }, "back_urls"=> { "success"=> "https=>//www.success.com", "failure"=> "http=>//www.failure.com", "pending"=> "http=>//www.pending.com" }, "payment_methods"=> { "excluded_payment_methods"=> [ { "id"=> "amex" } ], "excluded_payment_types"=> [ { "id"=> "ticket" } ], "installments"=> 12 } } } end end