Sha256: 272d8f81d14d5cb5738493af15dfd576c29a1671eaa016ebb928ffe872c6ae22
Contents?: true
Size: 1.24 KB
Versions: 2
Compression:
Stored size: 1.24 KB
Contents
require 'spec_helper' require 'engineyard/cli' describe EY::CLI::API do it "gets the api token from ~/.eyrc if possible" do write_eyrc({"api_token" => "asdf"}) EY::CLI::API.new('http://fake.local', EY::CLI::UI.new).token.should == "asdf" clean_eyrc end it "uses the token from $ENGINEYARD_API_TOKEN if set" do ENV['ENGINEYARD_API_TOKEN'] = 'envtoken' EY::CLI::API.new('http://fake.local', EY::CLI::UI.new).token.should == 'envtoken' ENV.delete('ENGINEYARD_API_TOKEN') end context "without saved api token" do before(:each) do clean_eyrc FakeWeb.register_uri(:post, "http://fake.local/api/v2/authenticate", :body => %|{"api_token": "asdf"}|, :content_type => 'application/json') EY::CLI::UI::Prompter.enable_mock! EY::CLI::UI::Prompter.add_answer "my@email.example.com" EY::CLI::UI::Prompter.add_answer "secret" @api = EY::CLI::API.new('http://fake.local', EY::CLI::UI.new) end it "asks you for your credentials" do EY::CLI::UI::Prompter.questions.should == ["Email: ","Password: "] end it "gets the api token" do @api.token.should == "asdf" end it "saves the api token to ~/.eyrc" do read_eyrc.should == {"api_token" => "asdf"} end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
engineyard-2.0.0.pre1 | spec/engineyard/cli/api_spec.rb |
engineyard-1.7.0.pre2 | spec/engineyard/cli/api_spec.rb |