Sha256: e238600d07042a1d1e3a1898b601c9087db34b0e075d5bb6494034ece3d399ea
Contents?: true
Size: 963 Bytes
Versions: 2
Compression:
Stored size: 963 Bytes
Contents
require "spec_helper" describe TriviaCrack::API::Login do let(:client) { (Class.new(APIStub) { include TriviaCrack::API::Login }).new } let(:response) { double(code: code, body: raw_data) } before { allow(Unirest).to receive(:post) { response } } describe "#login" do subject { client.login email, password } let(:email) { "user@example.com" } let(:password) { "password123" } let(:raw_data) { SpecData.get "login.json" } context 'given that the request is successful' do let(:code) { 200 } it { expect(TriviaCrack::Parsers::SessionParser).to receive(:parse).once; subject } its(:user_id) { is_expected.to be 111 } its(:username) { is_expected.to eq "example" } its(:session_id) { is_expected.to eq "session123" } end context 'given that the request is fails' do let(:code) { 400 } it { expect{ subject }.to raise_error TriviaCrack::Errors::RequestError } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
triviacrack-0.2.0 | spec/api/login_spec.rb |
triviacrack-0.1.0 | spec/api/login_spec.rb |