Sha256: c2a5f57d39a7cf1815aa797554c96b270a0a90ee074eee38d09a18fc189ffdf2
Contents?: true
Size: 1.54 KB
Versions: 2
Compression:
Stored size: 1.54 KB
Contents
require 'spec_helper' describe EY::API do it "gets the api token from ~/.eyrc if possible" do write_config({"api_token" => "asdf"}, '~/.eyrc') EY::API.new.should == EY::API.new("asdf") end context "fetching the token from EY cloud" do before(:each) do FakeWeb.register_uri(:post, "https://cloud.engineyard.com/api/v2/authenticate", :body => %|{"api_token": "asdf"}|) @token = EY::API.fetch_token("a@b.com", "foo") end it "returns an EY::API" do @token.should == "asdf" end it "puts the api token into .eyrc" do load_config('~/.eyrc')["api_token"].should == "asdf" end end describe "saving the token" do context "without a custom endpoint" do it "saves the api token at the root of the data" do EY::API.save_token("asdf") load_config('~/.eyrc')["api_token"].should == "asdf" end end context "with a custom endpoint" do before do write_config({"endpoint" => "http://localhost/"}, 'ey.yml') EY::API.save_token("asdf") end it "saves the api token" do load_config('~/.eyrc').should == {"http://localhost/" => {"api_token" => "asdf"}} end it "reads the api token" do EY::API.read_token.should == "asdf" end end end it "raises InvalidCredentials when the credentials are invalid" do FakeWeb.register_uri(:post, "https://cloud.engineyard.com/api/v2/authenticate", :status => 401) lambda { EY::API.fetch_token("a@b.com", "foo") }.should raise_error(EY::Error) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
engineyard-0.2.9 | spec/engineyard/api_spec.rb |
engineyard-0.2.7 | spec/engineyard/api_spec.rb |