Sha256: 56ddf0fed38b179bc2730cb62f1df5205ab07c281a0c2711d085a708f522152c
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
require 'spec_helper' RSpec.describe TeslaApi::Client do subject(:tesla_api) { TeslaApi::Client.new(ENV["TESLA_EMAIL"]) } describe "#token=" do it "sets a Bearer token" do tesla_api.token = Faker::Lorem.characters(32) expect(tesla_api.class.headers).to include({"Authorization" => /Bearer [a-z0-9]{32}/}) end end describe "#login!", vcr: { cassette_name: "client-login" } do it { is_expected.to be_a(TeslaApi::Client) } it "logs into the API" do tesla_api.login!(ENV["TESLA_PASS"]) expect(a_request(:post, "https://#{URI.parse(tesla_api.class.base_uri).host}/oauth/token")).to have_been_made.once end it "obtains a Bearer token" do tesla_api.login!(ENV["TESLA_PASS"]) expect(tesla_api.token).to match(/[a-z0-9]{32}/) end it "sets a Bearer token header" do tesla_api.login!(ENV["TESLA_PASS"]) 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tesla_api-1.2.0 | spec/lib/tesla_api/client_spec.rb |
tesla_api-1.1.0 | spec/lib/tesla_api/client_spec.rb |