Sha256: d734c2c4f3046e069ce4d61008bfa45b53048e8ea063363e8db36ef15d12809f

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require "spec_helper"

describe Freemle::Client do
  describe "#initialize" do
    subject { Freemle::Client.new(opts) }
    let(:opts) { Hash.new }

    specify { expect { subject }.to raise_error(KeyError) }

    context "given app_name" do
      before { opts[:app_name] = "name" }

      specify { expect { subject }.to raise_error(KeyError) }

      context "and api_key" do
        before { opts[:api_key] = "secret" }

        it { should be_instance_of(Freemle::Client) }
        its(:base_url) { should eq(Freemle::Client::BASE_URL) }
        its(:app_name) { should eq("name") }
        its(:api_key) { should eq("secret") }
      end
    end
  end

  context "configured" do
    let(:client) { Freemle::Client.new(app_name: "app", api_key: "secret") }

    describe "#customers" do
      subject { client.customers }

      it { should be_instance_of(Freemle::Client::Resource) }
      its(:singular) { should eq(:customer) }
      its(:plural) { should eq(:customers) }
    end

    describe "#invoices" do
      subject { client.invoices }

      it { should be_instance_of(Freemle::Client::Resource) }
      its(:singular) { should eq(:invoice) }
      its(:plural) { should eq(:invoices) }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
freemle-1.0.1 spec/freemle/client_spec.rb