Sha256: d806c70796adec553038c50b0e9ba94456f3c5c7dc853c974e0b653665d46e1d
Contents?: true
Size: 1.93 KB
Versions: 7
Compression:
Stored size: 1.93 KB
Contents
describe DeployGate::Session do describe "#login?" do it "call check api" do call_check = false allow(DeployGate::API::V1::Session).to receive(:check) { call_check = true } DeployGate::Session.new.login? expect(call_check).to be_truthy end end describe "#login" do it "success" do data = { :error => false, :name => 'test', :token => 'token' } call_save = false allow(DeployGate::API::V1::Session).to receive(:login).and_return(data) allow(DeployGate::Session).to receive(:save) { call_save = true } DeployGate::Session.delete expect { DeployGate::Session.login('test@example.com', 'test') }.not_to raise_error expect(call_save).to be_truthy expect(DeployGate::Session.new.login?).to be_truthy end it "failed" do data = { :error => true, :message => 'error message' } allow(DeployGate::API::V1::Session).to receive(:login).and_return(data) expect { DeployGate::Session.login('test@example.com', 'test') }.to raise_error(DeployGate::Session::LoginError) end end describe "#save" do it "call Config.write" do config_data = { :name => 'test', :token => 'token' } call_config_write_and_fix_config = false allow(DeployGate::Config::Credential).to receive(:write) { |c| call_config_write_and_fix_config = c == config_data} DeployGate::Session.save(config_data[:name], config_data[:token]) expect(call_config_write_and_fix_config).to be_truthy end end describe "#delete" do it "call save" do call_save = false allow(DeployGate::Session).to receive(:save) { |name, token| call_save = (name == '' && token == '')} DeployGate::Session.delete expect(call_save).to be_truthy login = DeployGate::Session.new.login? expect(login).to be_falsey end end end
Version data entries
7 entries across 7 versions & 1 rubygems