Sha256: 9da13463846c030a062df882dfed77a792152f653ae6fa270fd1b0cc60fb726f

Contents?: true

Size: 1.4 KB

Versions: 11

Compression:

Stored size: 1.4 KB

Contents

require 'spec_helper'

describe TresDelta::Customer do
  describe "initalization" do
    let(:name) { "Johnny B" }

    context "new customer" do
      let(:customer) { TresDelta::Customer.new(:name => name) }

      it "generates a random vault key" do
        expect(customer.vault_key.size).to eq(24)
      end

      it "uses the assigned name" do
        expect(customer.name).to eq(name)
      end
    end

    context "existing customer" do
      let(:vault_key) { SecureRandom.hex(12) }
      let(:customer) { TresDelta::Customer.new(:vault_key => vault_key) }

      it "is initialized with a given vault key" do
        expect(customer.vault_key).to eq(vault_key)
      end
    end
  end

  describe "#create" do
    let(:customer) { TresDelta::Customer.create(customer_data) }

    context "good customer info" do
      let(:vault_key) { SecureRandom.hex(6) }
      let(:customer_data) { { name: "Joe Tester", vault_key: vault_key } }

      it "creates the customer" do
        expect(customer).to be_a(TresDelta::Customer)
      end

      it "has the initialized values" do
        expect(customer.vault_key).to eq(vault_key)
        expect(customer.name).to eq(customer_data[:name])
      end
    end

    context "bad customer info" do
      let(:customer_data) { Hash.new }

      it "raises an error" do
        expect { customer }.to raise_exception(TresDelta::Customer::InvalidCustomer)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
tres_delta-0.2.0 spec/tres_delta/customer_spec.rb
tres_delta-0.1.5 spec/tres_delta/customer_spec.rb
tres_delta-0.1.4.3 spec/tres_delta/customer_spec.rb
tres_delta-0.1.4.2 spec/tres_delta/customer_spec.rb
tres_delta-0.1.4.1 spec/tres_delta/customer_spec.rb
tres_delta-0.1.4 spec/tres_delta/customer_spec.rb
tres_delta-0.1.3 spec/tres_delta/customer_spec.rb
tres_delta-0.1.2 spec/tres_delta/customer_spec.rb
tres_delta-0.1.1 spec/tres_delta/customer_spec.rb
tres_delta-0.1.0 spec/tres_delta/customer_spec.rb
tres_delta-0.0.2 spec/tres_delta/customer_spec.rb