Sha256: 98c6ae802373534121c7ff1486551fa2021ef0c0da99be99820aa4aef977e231

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 KB

Contents

require "spec_helper"

describe Paymill::CreditCard do
  let(:valid_attributes) do
    {
      card_type:    "visa",
      country:      "germany",
      expire_month: 12,
      expire_year:  2012,
      card_holder:  "Stefan Sprenger",
      last4:        "1111"
    }
  end

  let (:credit_card) do
    Paymill::CreditCard.new(valid_attributes)
  end

  describe "#initialize" do
    it "initializes all attributes correctly" do
      credit_card.card_type.should eql("visa")
      credit_card.country.should eql("germany")
      credit_card.expire_month.should eql(12)
      credit_card.expire_year.should eq(2012)
      credit_card.card_holder.should eql("Stefan Sprenger")
      credit_card.last4.should eql("1111")
    end
  end

  describe ".find" do
    it "makes a new GET request using the correct API endpoint to receive a specific creditcard" do
      Paymill.should_receive(:request).with(:get, "creditcards/123", {}).and_return("data" => {})
      Paymill::CreditCard.find("123")
    end
  end

  describe ".all" do
    it "makes a new GET request using the correct API endpoint to receive all creditcards" do
      Paymill.should_receive(:request).with(:get, "creditcards/", {}).and_return("data" => {})
      Paymill::CreditCard.all
    end
  end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
paymill-0.0.3 spec/paymill/credit_card_spec.rb