Sha256: defabfe3be85da4fe521751450ece7b9e2919b3e8c5c708b0142d9362406cccd
Contents?: true
Size: 1.33 KB
Versions: 33
Compression:
Stored size: 1.33 KB
Contents
describe QuizApiClient::Services::QuizAnalysesService 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_id: 1 } } let(:stubbed_response) { { 'id' => '1' } } let(:expected_url) do "https://#{host}/api/quizzes/#{params[:quiz_id]}/stats/quiz_analysis" end 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 result = subject.get(params: params, token: 'token') expect(result.parsed_response).to eql(stubbed_response) end it 'raises an error when no quiz_id is specified' do params = {} expect do subject.get(params: params, token: 'token') end.to raise_error 'Quiz Id Required' end context 'response' do it 'returns the response with the correct status code' do response = subject.get(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