Sha256: b624a24cd0630a4ed3935c436d706920b61de09134605fa5b2a4cbe6c69276e9
Contents?: true
Size: 1.54 KB
Versions: 13
Compression:
Stored size: 1.54 KB
Contents
require 'spec_helper' require 'generators/jax/all' describe Jax::Plugin::Credentials do def shell @shell ||= GenSpec::Shell.new end subject do Jax::Plugin::Credentials.new :home => local("."), :shell => shell end it "with new account" do shell.input.stub!(:gets).and_return 'missing@gmail.com', 'password', 'password' subject.api_key.should == "WXTzIXC2ODdbLAyvVL9p" end context "with missing config file and valid existing credentials" do before :each do shell.input.stub!(:gets).and_return 'sinisterchipmunk@gmail.com', 'password' end it "should return api key" do subject.api_key.should == "WXTzIXC2ODdbLAyvVL9p" end it "should create config file" do subject.api_key File.should exist(local "./.jax") end end it "with missing config file and invalid credentials for an existing account" do shell.input.stub!(:gets).and_return 'missing@gmail.com', 'invalid' proc { subject.api_key }.should raise_error(RuntimeError) end it "with missing api key" do shell.input.stub!(:gets).and_return 'missing@gmail.com', 'password', 'password' subject.api_key shell.output.string.should =~ /email/i end it "with api key" do create_file(".jax") { |f| f.print 'api_key: "1234"' } subject.api_key.should == "1234" end it "default home" do Jax::Plugin::Credentials.new.home.should == Thor::Util.user_home end it "override home" do Jax::Plugin::Credentials.new(:home => ".").home.should == File.expand_path(".") end end
Version data entries
13 entries across 13 versions & 1 rubygems