Sha256: a9cca6d80c07c664ccf4a0a30fa9e0b6417f39418aef65b51ea95ac32f114174

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

require "spec_helper"

describe Paymill::Preauthorization do
  let(:valid_attributes) do
    {
      payment: "pay_d43cf0ee969d9847512b",
      amount: 4200,
      currency: "EUR",
      source: "paymill-ruby"
    }
  end

  let (:preauthorization) do
    Paymill::Preauthorization.new(valid_attributes)
  end

  describe "#initialize" do
    it "initializes all attributes correctly" do
      preauthorization.payment.should eql("pay_d43cf0ee969d9847512b")
      preauthorization.amount.should eql(4200)
      preauthorization.currency.should eql("EUR")
      preauthorization.source.should eql("paymill-ruby")
    end
  end

  describe ".create" do
    it "makes a new POST request using the correct API endpoint" do
      Paymill.should_receive(:request).with(:post, "preauthorizations", valid_attributes).and_return("data" => {})
      Paymill::Preauthorization.create(valid_attributes)
    end
  end

  describe ".delete" do
    it "makes a new DELETE request using the correct API endpoint" do
      Paymill.should_receive(:request).with(:delete, "preauthorizations/123", {}).and_return(true)
      Paymill::Preauthorization.delete("123")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
paymill-0.5.1 spec/paymill/preauthorization_spec.rb
paymill-0.5.0 spec/paymill/preauthorization_spec.rb