Sha256: 093e763d0402fa4e458ee55d4e19528c403586857fb29f0dba05379abc690571
Contents?: true
Size: 1.64 KB
Versions: 23
Compression:
Stored size: 1.64 KB
Contents
describe QuizApiClient::Services::QuizSessionService do let(:host) { 'api.host' } let(:config) { QuizApiClient::Config.new { |c| c.host = host } } let(:subject) { described_class.new(config) } describe '#update' do let(:params) { { id: 1, time_limit_seconds: 10 } } let(:stubbed_response) { { 'id' => '1' } } let(:expected_url) { "https://#{host}/api/quiz_sessions/#{params[:id]}" } let(:expected_body) { { quiz_session: { id: 1, time_limit_seconds: 10 } }.to_json } let(:status_code) { 200 } before do stub_request(:patch, expected_url) .with(body: expected_body) .to_return( status: status_code, body: stubbed_response.to_json, headers: { 'Content-Type' => 'application/json' } ) end it 'patches to quiz_api/api/quiz_sessions and returns the response' do response = subject.update(params: params, token: 'token') expect(response.parsed_response).to eql(stubbed_response) end end describe '#show' do let(:params) { { id: 1 } } let(:stubbed_response) { { 'id' => 1, 'time_limit_seconds' => 10 } } let(:expected_url) { "https://#{host}/api/quiz_sessions/#{params[:id]}" } let(:status_code) { 200 } before do stub_request(:get, expected_url) .to_return( status: status_code, body: stubbed_response.to_json, headers: { 'Content-Type' => 'application/json' } ) end it 'gets from quiz_api/api/quiz_sessions and returns the response' do response = subject.show(params: params, token: 'token') expect(response.parsed_response).to eql(stubbed_response) end end end
Version data entries
23 entries across 23 versions & 1 rubygems