Sha256: b962c6710ceab34de9f6c1046f2693cd562b219b719e29e9f6335edacdf13fa0
Contents?: true
Size: 1.79 KB
Versions: 2
Compression:
Stored size: 1.79 KB
Contents
require 'spec_helper' describe Enceladus::Configuration::Api do describe "#connect" do subject { Enceladus::Configuration::Api.instance.connect(api_key) } let(:api_key) { "token" } context "when the provided api_key is not valid" do before do stub_request(:get, /api.themoviedb.org\/3\/configuration/). to_return(status: 401, body: ErrorResponse.new(7, "Invalid API key: You must be granted a valid key.").to_json) end it "should set Enceladus::Configuration::Api api_key as nil" do subject expect(Enceladus::Configuration::Api.instance.api_key).to be_nil end it "should call Enceladus::Configuration::Image.instance.reset!" do expect(Enceladus::Configuration::Image.instance).to receive(:reset!) subject end it "should return false" do should eq(false) end end context "when the provided api_key is valid" do before do stub_request(:get, /api.themoviedb.org\/3\/configuration/). to_return(status: 200, body: ConfigurationResponse.new.to_json) end it "should save Enceladus::Configuration::Api api_key" do subject expect(Enceladus::Configuration::Api.instance.api_key).to eq(api_key) end it "should return true" do should eq(true) end end end describe "#url_for" do subject { Enceladus::Configuration::Api.instance.url_for(action, params) } let(:action) { "movies" } let(:params) { { term: "Sasha Grey" } } before do expect(Enceladus::Configuration::Api.instance).to receive(:api_key).and_return("token") end it "should return the full endpoint URL based on the provided args" do should eq "https://api.themoviedb.org/3/movies?term=Sasha+Grey&api_key=token" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
enceladus-0.0.3 | spec/enceladus/configuration/api_spec.rb |
enceladus-0.0.2 | spec/enceladus/configuration/api_spec.rb |