Sha256: ad2334316acc398c3a6864b027a03767723244d5f36b574f3f41ef1641a1fd39

Contents?: true

Size: 840 Bytes

Versions: 3

Compression:

Stored size: 840 Bytes

Contents

require 'spec_helper'

RSpec.describe TeslaApi::Client do
  subject(:tesla_api) { TeslaApi::Client.new(ENV["TESLA_EMAIL"], ENV["TESLA_PASS"], ENV["TESLA_CLIENT_ID"], ENV["TESLA_CLIENT_SECRET"]) }

  describe "#initialize", vcr: { cassette_name: "client-initialize" } do
    it { is_expected.to be_a(TeslaApi::Client) }

    it "logs into the API" do
      base_uri = URI.parse(tesla_api.class.base_uri)
      expect(a_request(:post, "https://#{base_uri.host}/oauth/token")).to have_been_made.once
    end

    it "sets a Bearer token" do
      expect(tesla_api.class.headers).to include({"Authorization" => /Bearer [a-z0-9]{32}/})
    end
  end

  describe "#vehicles", vcr: {cassette_name: "client-vehicles"} do
    it "lists the vehicles on the account" do
      expect(tesla_api.vehicles).to include(TeslaApi::Vehicle)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tesla_api-1.0.0 spec/lib/tesla_api/client_spec.rb
tesla_api-0.9.0 spec/lib/tesla_api/client_spec.rb
tesla_api-0.1.0 spec/lib/tesla_api/client_spec.rb