spec/deploygate/api/v1/session_spec.rb in deploygate-0.0.4 vs spec/deploygate/api/v1/session_spec.rb in deploygate-0.0.5

- old
+ new

@@ -1,33 +1,52 @@ describe DeployGate::API::V1::Session do - describe "#check" do + describe "#show" do it "logined" do token = 'token' name = 'test' response = { :error => false, :because => '', - :results => {:name => name} + :results => {'name' => name} } stub_request(:get, "#{API_ENDPOINT}/sessions/user"). with(:headers => { 'AUTHORIZATION' => token }). to_return(:body => response.to_json) - result = DeployGate::API::V1::Session.check(name, token) - expect(result).to be_truthy + results = DeployGate::API::V1::Session.show(token) + expect(results).to eql response[:results] end it "not login" do token = 'token' - name = 'test' response = { :error => true, :because => 'error message' } stub_request(:get, "#{API_ENDPOINT}/sessions/user"). with(:headers => { 'AUTHORIZATION' => token }). to_return(:body => response.to_json) + + results = DeployGate::API::V1::Session.show(token) + expect(results).to eql response[:results] + end + end + describe "#check" do + it "logined" do + token = 'token' + name = 'test' + results = {'name' => name} + allow(DeployGate::API::V1::Session).to receive(:show).and_return(results) + + result = DeployGate::API::V1::Session.check(name, token) + expect(result).to be_truthy + end + + it "not login" do + token = 'token' + name = 'test' + allow(DeployGate::API::V1::Session).to receive(:show).and_return(nil) result = DeployGate::API::V1::Session.check(name, token) expect(result).to be_falsey end end