Sha256: 2ce63f1bfaf8c672abbf080a0193d9f33461cec8b097280d36b4e417aba78e4b
Contents?: true
Size: 1.37 KB
Versions: 33
Compression:
Stored size: 1.37 KB
Contents
describe QuizApiClient::Services::QuizSessionEventsService do let(:host) { 'api.host' } let(:config) { QuizApiClient::Config.new { |c| c.host = host } } let(:subject) { described_class.new(config) } describe '#list' do let(:params) { { quiz_session_id: 1 } } let(:stubbed_response) { { 'id' => '1' } } let(:expected_url) { "https://#{host}/api/quiz_sessions/#{params[:quiz_session_id]}/quiz_session_events" } let(:expected_body) { '' } let(:status_code) { 200 } before do stub_request(:get, expected_url) .with(body: expected_body) .to_return( status: status_code, body: stubbed_response.to_json, headers: { 'Content-Type' => 'application/json' } ) end it 'posts to quiz_api/api/quizzes and returns the response' do response = subject.list(params: params, token: 'token') expect(response.parsed_response).to eql(stubbed_response) end it 'raises an error when no quiz_session_id is specified' do params = {} expect do subject.list(params: params, token: 'token') end.to raise_error 'Quiz Session Id Required' end context 'response' do it 'returns the response with the correct status code' do response = subject.list(params: params, token: 'token') expect(response.code).to eq(status_code) end end end end
Version data entries
33 entries across 33 versions & 1 rubygems