quiz_api_client 4.3.0 → 4.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -48
- data/Rakefile +0 -29
- data/lib/quiz_api_client/services/courses_service.rb +37 -0
- data/lib/quiz_api_client/version.rb +1 -1
- data/lib/quiz_api_client.rb +5 -0
- data/spec/quiz_api_client_spec.rb +7 -0
- data/spec/services/courses_service_spec.rb +103 -0
- data/spec/spec_helper.rb +1 -25
- metadata +11 -86
- data/spec/contracts/interaction_types_service_spec.rb +0 -22
- data/spec/contracts/item_analyses_service_spec.rb +0 -59
- data/spec/contracts/items_service_spec.rb +0 -59
- data/spec/contracts/qti_imports_service_spec.rb +0 -34
- data/spec/contracts/quiz_clone_job_service_spec.rb +0 -20
- data/spec/contracts/quiz_clone_jobs_service_spec.rb +0 -21
- data/spec/contracts/quiz_entries_service_spec.rb +0 -125
- data/spec/contracts/quiz_service_spec.rb +0 -68
- data/spec/contracts/quiz_session_events_service_spec.rb +0 -30
- data/spec/contracts/quiz_session_result_service_spec.rb +0 -42
- data/spec/contracts/quiz_session_service_spec.rb +0 -56
- data/spec/contracts/quiz_sessions_service_spec.rb +0 -28
- data/spec/contracts/quiz_sync_job_service_spec.rb +0 -21
- data/spec/contracts/quiz_sync_jobs_service_spec.rb +0 -21
- data/spec/contracts/quizzes_service_spec.rb +0 -80
- data/spec/contracts/session_item_results_service_spec.rb +0 -60
- data/spec/contracts/session_items_service_spec.rb +0 -21
- data/spec/contracts/shared_banks_spec.rb +0 -366
- data/spec/contracts/shared_examples/http_delete_example.rb +0 -56
- data/spec/contracts/shared_examples/http_get_example.rb +0 -139
- data/spec/contracts/shared_examples/http_patch_example.rb +0 -60
- data/spec/contracts/shared_examples/http_post_example.rb +0 -68
- data/spec/contracts/shared_examples/http_put_example.rb +0 -60
- data/spec/support/pact_config.rb +0 -64
- data/spec/support/pact_helper.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 316ba7a8bde533e2ef09e6e0a5e2c443a597ae3bfda7c00cf5280c2ab5e75bb0
|
4
|
+
data.tar.gz: ec869a63880d44c2fb7920f95dd80b042671c954bb4a5a972d6ebbc00261f5b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3611bb4fb2775b6a96669bd276cfa513cd47f1177dd98b76757fea5311241e4066184228dce6c9aa78b9f70a004ae908b56981870301f21527ae87068e7a29a0
|
7
|
+
data.tar.gz: 4f9988a4c3791f69c25b53eb9db65194643d2d1639c8327f942a71e4264e7662c17f24a6094d6dfd58fd4168a6e53e78da613ba8f268f745d209b615838d62ac
|
data/README.md
CHANGED
@@ -187,51 +187,3 @@ Then, run `bundle exec rake spec` to run the tests.
|
|
187
187
|
You can also run `bundle exec rake console` for an interactive prompt that will allow you to experiment.
|
188
188
|
|
189
189
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
190
|
-
|
191
|
-
When you add or modify a service, be sure to add or modify contract tests!
|
192
|
-
|
193
|
-
## Contract Tests
|
194
|
-
|
195
|
-
We use [Pact](https://docs.pact.io/) for our contract testing. To generate
|
196
|
-
a Pact file, run `bin/contracts-generate`. The script will generate the Pact
|
197
|
-
file and place it in the pacts/ directory. It will also attempt to publish the
|
198
|
-
Pact file to a local Pact Broker.
|
199
|
-
|
200
|
-
### Development Workflow:
|
201
|
-
|
202
|
-
1. In the quiz_api repo, spin up the Quiz API service with `bin/dev-setup`
|
203
|
-
2. In the quiz_pact_broker repo, spin up a Pact Broker with `bin/dev-setup`
|
204
|
-
3. In the quiz_api repo, write Pact provider states in the
|
205
|
-
spec/service_consumers/api/quiz_api_client_ruby/ directory as needed
|
206
|
-
4. In this repo's spec/contracts/ directory, write or modify a contract test
|
207
|
-
5. In this repo, run `bin/contracts-generate` to generate a Pact file and
|
208
|
-
publish it to the Pact Broker
|
209
|
-
6. In the quiz_api repo, run `bin/contracts` to pull the new Pact file from
|
210
|
-
the Pact Broker and run the updated contract tests against the Quiz API service
|
211
|
-
|
212
|
-
Bonus: You can view your Pact file in the Pact Broker at http://pact-broker.docker
|
213
|
-
along with some cool goodies!
|
214
|
-
|
215
|
-
### Debugging Failures
|
216
|
-
|
217
|
-
Pact has some basic RSpec output for failed specs. It also keeps a log in
|
218
|
-
`log/pact.log` and offers general pointers for debugging.
|
219
|
-
|
220
|
-
Above all, learn the Pact [basics](https://docs.pact.io/documentation/matching.html).
|
221
|
-
|
222
|
-
### What should contract tests cover?
|
223
|
-
|
224
|
-
The aim of contract testing here is *not* to test all functional requirements
|
225
|
-
of the Quiz API service. Rather, the goal is to ensure changes to the Quiz API
|
226
|
-
service don't break its clients. We can best accomplish this with the
|
227
|
-
following contract test coverage:
|
228
|
-
|
229
|
-
- Basic happy path requests for all endpoints (POST, GET, PUT, DELETE)
|
230
|
-
- Basic error paths for all endpoints (verify the error messages and/or HTTP
|
231
|
-
response codes are accurate)
|
232
|
-
- Resource state management; for example, when a quiz attempt is submitted but
|
233
|
-
not yet graded
|
234
|
-
- Special edge case errors
|
235
|
-
|
236
|
-
Again, what *not* to test: the functional behavior of the service; for
|
237
|
-
example, a series of sequential API calls to test a full user scenario.
|
data/Rakefile
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
|
-
require 'pact_broker/client/tasks'
|
3
2
|
require 'rspec/core/rake_task'
|
4
|
-
require_relative './spec/support/pact_config'
|
5
3
|
|
6
4
|
RSpec::Core::RakeTask.new(:spec)
|
7
5
|
|
@@ -19,30 +17,3 @@ task :console do
|
|
19
17
|
ARGV.clear
|
20
18
|
Pry.start
|
21
19
|
end
|
22
|
-
|
23
|
-
# see https://github.com/pact-foundation/pact_broker-client/blob/master/README.md
|
24
|
-
namespace :broker do
|
25
|
-
PactBroker::Client::PublicationTask.new(:local) do |task|
|
26
|
-
prepare_pact_files_for_publishing(task)
|
27
|
-
end
|
28
|
-
|
29
|
-
PactBroker::Client::PublicationTask.new(:jenkins_post_merge) do |task|
|
30
|
-
prepare_pact_files_for_publishing(task)
|
31
|
-
end
|
32
|
-
|
33
|
-
def prepare_pact_files_for_publishing(task)
|
34
|
-
task.pattern = 'pacts/*.json'
|
35
|
-
|
36
|
-
task.pact_broker_base_url = PactConfig.broker_host
|
37
|
-
task.pact_broker_basic_auth = {
|
38
|
-
username: PactConfig.broker_username,
|
39
|
-
password: PactConfig.broker_password
|
40
|
-
}
|
41
|
-
|
42
|
-
task.consumer_version = PactConfig.consumer_version
|
43
|
-
puts "Consumer version: #{task.consumer_version}"
|
44
|
-
|
45
|
-
task.tag = PactConfig.consumer_tag
|
46
|
-
puts "Pact file tagged with: #{task.tag}"
|
47
|
-
end
|
48
|
-
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module QuizApiClient::Services
|
2
|
+
class CoursesService < BaseApiService
|
3
|
+
def create(params:, token: nil)
|
4
|
+
post_to_quiz_api(params: params, token: token)
|
5
|
+
end
|
6
|
+
|
7
|
+
def update(params:, token: nil)
|
8
|
+
patch_to_quiz_api(params: params, token: token)
|
9
|
+
end
|
10
|
+
|
11
|
+
def destroy(params:, token: nil)
|
12
|
+
delete_from_quiz_api(params: params, token: token)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def post_to_quiz_api(params:, token:)
|
18
|
+
client(token: token).post(
|
19
|
+
'/api/courses',
|
20
|
+
course: params
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
def patch_to_quiz_api(params:, token:)
|
25
|
+
client(token: token).patch(
|
26
|
+
"/api/courses/#{params[:canvas_id]}",
|
27
|
+
course: params.dup.tap { |p| p.delete(:canvas_id) }
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
def delete_from_quiz_api(params:, token:)
|
32
|
+
client(token: token).delete(
|
33
|
+
"/api/courses/#{params[:canvas_id]}"
|
34
|
+
)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/quiz_api_client.rb
CHANGED
@@ -22,6 +22,10 @@ module QuizApiClient
|
|
22
22
|
@_config ||= QuizApiClient::Config.new
|
23
23
|
end
|
24
24
|
|
25
|
+
def courses_service
|
26
|
+
@_courses_service ||= Services::CoursesService.new(config)
|
27
|
+
end
|
28
|
+
|
25
29
|
def jwt_service
|
26
30
|
@_jwt_service ||= QuizApiClient::Services::JwtService.new(config)
|
27
31
|
end
|
@@ -114,6 +118,7 @@ require 'quiz_api_client/http_request/metrics'
|
|
114
118
|
require 'quiz_api_client/services/jwt_service'
|
115
119
|
require 'quiz_api_client/services/base_api_service'
|
116
120
|
|
121
|
+
require 'quiz_api_client/services/courses_service'
|
117
122
|
require 'quiz_api_client/services/interaction_types_service'
|
118
123
|
require 'quiz_api_client/services/item_analyses_service'
|
119
124
|
require 'quiz_api_client/services/items_service'
|
@@ -51,6 +51,13 @@ describe QuizApiClient do
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
+
describe '#courses_service' do
|
55
|
+
it 'creates the service' do
|
56
|
+
expect(QuizApiClient::Services::CoursesService).to receive(:new).with(subject.config)
|
57
|
+
subject.courses_service
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
54
61
|
describe '#quizzes_service' do
|
55
62
|
it 'should create the service' do
|
56
63
|
expect(QuizApiClient::Services::QuizzesService).to receive(:new).with(subject.config)
|
@@ -0,0 +1,103 @@
|
|
1
|
+
describe QuizApiClient::Services::CoursesService do
|
2
|
+
let(:host) { 'api.host' }
|
3
|
+
let(:config) { QuizApiClient::Config.new { |c| c.host = host } }
|
4
|
+
let(:subject) { described_class.new(config) }
|
5
|
+
|
6
|
+
describe '#create' do
|
7
|
+
let(:params) do
|
8
|
+
{
|
9
|
+
title: 'foo',
|
10
|
+
canvas_id: 2,
|
11
|
+
is_blueprint: true
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:response) do
|
16
|
+
{
|
17
|
+
'id' => '4',
|
18
|
+
'title' => 'foo',
|
19
|
+
'canvas_id' => '2',
|
20
|
+
'is_blueprint' => true,
|
21
|
+
'created_at' => '2022-06-22T18:59:27.577Z',
|
22
|
+
'updated_at' => '2022-06-22T18:59:27.577Z'
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
let(:expected_url) { "https://#{host}/api/courses" }
|
27
|
+
|
28
|
+
before do
|
29
|
+
stub_request(:post, expected_url)
|
30
|
+
.with(body: { course: params }.to_json)
|
31
|
+
.to_return(
|
32
|
+
status: 201,
|
33
|
+
body: response.to_json,
|
34
|
+
headers: { 'Content-Type' => 'application/json' }
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'posts to the correct endpoint and returns the response' do
|
39
|
+
expect(
|
40
|
+
subject.create(params: params, token: 'token').parsed_response
|
41
|
+
).to eq(response)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#update' do
|
46
|
+
let(:params) do
|
47
|
+
{
|
48
|
+
canvas_id: 4,
|
49
|
+
title: 'foo',
|
50
|
+
is_blueprint: true
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
let(:response) do
|
55
|
+
{
|
56
|
+
'id' => '4',
|
57
|
+
'title' => 'foo',
|
58
|
+
'canvas_id' => '2',
|
59
|
+
'is_blueprint' => true,
|
60
|
+
'created_at' => '2022-06-22T18:59:27.577Z',
|
61
|
+
'updated_at' => '2022-06-22T18:59:27.577Z'
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
let(:expected_url) { "https://#{host}/api/courses/4" }
|
66
|
+
|
67
|
+
before do
|
68
|
+
stub_request(:patch, expected_url)
|
69
|
+
.with(body: { course: params.slice(:title, :is_blueprint) }.to_json)
|
70
|
+
.to_return(
|
71
|
+
status: 200,
|
72
|
+
body: response.to_json,
|
73
|
+
headers: { 'Content-Type' => 'application/json' }
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'pathces to the correct endpoint and returns the response' do
|
78
|
+
expect(
|
79
|
+
subject.update(params: params, token: 'token').parsed_response
|
80
|
+
).to eq(response)
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'does not modify params' do
|
84
|
+
subject.update(params: params, token: 'token')
|
85
|
+
expect(params).to eq params
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe '#destroy' do
|
90
|
+
let(:params) { { canvas_id: 1 } }
|
91
|
+
let(:expected_url) { "https://#{host}/api/courses/1" }
|
92
|
+
|
93
|
+
before do
|
94
|
+
stub_request(:delete, expected_url).to_return(status: 204)
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'deletes to the correct endpoint and returns the response' do
|
98
|
+
response = subject.destroy(params: params, token: 'token')
|
99
|
+
expect(response.code).to eq 204
|
100
|
+
expect(response.body).to be_nil
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'pact/consumer/rspec'
|
2
1
|
require 'pry'
|
3
2
|
require 'simplecov'
|
4
3
|
require 'webmock/rspec'
|
@@ -10,33 +9,10 @@ end
|
|
10
9
|
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
|
11
10
|
require 'quiz_api_client'
|
12
11
|
|
13
|
-
Dir[File.dirname(__FILE__) + '/support/*.rb'].each { |f| require f }
|
14
|
-
Dir[File.dirname(__FILE__) + '/contracts/shared_examples/*.rb'].each { |f| require f }
|
15
|
-
|
16
12
|
WebMock.disable_net_connect!(
|
17
|
-
allow_localhost: true
|
18
|
-
allow: [PactConfig.broker_host]
|
13
|
+
allow_localhost: true
|
19
14
|
)
|
20
15
|
|
21
|
-
# see https://github.com/realestate-com-au/pact/blob/master/documentation/configuration.md
|
22
|
-
Pact.configure do |config|
|
23
|
-
config.diff_formatter = :list
|
24
|
-
config.logger.level = Logger::DEBUG
|
25
|
-
config.pact_dir = 'pacts'
|
26
|
-
config.pactfile_write_mode = :overwrite
|
27
|
-
config.pactfile_write_order = :chronological
|
28
|
-
end
|
29
|
-
|
30
|
-
Pact.service_consumer PactConfig::QUIZ_API_CLIENT_RUBY do
|
31
|
-
has_pact_with PactConfig::Providers::QUIZ_API do
|
32
|
-
mock_service :quiz_api do
|
33
|
-
port 1234
|
34
|
-
pact_specification_version '2.0.0'
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
16
|
RSpec.configure do |config|
|
40
|
-
config.filter_run_excluding :pact
|
41
17
|
config.before { allow_any_instance_of(::Logger).to receive(:info) }
|
42
18
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quiz_api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Slaughter
|
@@ -11,10 +11,10 @@ authors:
|
|
11
11
|
- Michael Hargiss
|
12
12
|
- Robin Kuss
|
13
13
|
- Ryan Taylor
|
14
|
-
autorequire:
|
14
|
+
autorequire:
|
15
15
|
bindir: exe
|
16
16
|
cert_chain: []
|
17
|
-
date: 2022-
|
17
|
+
date: 2022-08-08 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: httparty
|
@@ -72,34 +72,6 @@ dependencies:
|
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0'
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: pact
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
79
|
-
- - "~>"
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: '1.41'
|
82
|
-
type: :development
|
83
|
-
prerelease: false
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - "~>"
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: '1.41'
|
89
|
-
- !ruby/object:Gem::Dependency
|
90
|
-
name: pact_broker-client
|
91
|
-
requirement: !ruby/object:Gem::Requirement
|
92
|
-
requirements:
|
93
|
-
- - "~>"
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: '1.19'
|
96
|
-
type: :development
|
97
|
-
prerelease: false
|
98
|
-
version_requirements: !ruby/object:Gem::Requirement
|
99
|
-
requirements:
|
100
|
-
- - "~>"
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: '1.19'
|
103
75
|
- !ruby/object:Gem::Dependency
|
104
76
|
name: rake
|
105
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -184,7 +156,7 @@ dependencies:
|
|
184
156
|
- - ">="
|
185
157
|
- !ruby/object:Gem::Version
|
186
158
|
version: '0'
|
187
|
-
description:
|
159
|
+
description:
|
188
160
|
email:
|
189
161
|
- aslaughter@instructure.com
|
190
162
|
- jhiggins@instructure.com
|
@@ -206,6 +178,7 @@ files:
|
|
206
178
|
- lib/quiz_api_client/http_request/metrics.rb
|
207
179
|
- lib/quiz_api_client/json_formatter.rb
|
208
180
|
- lib/quiz_api_client/services/base_api_service.rb
|
181
|
+
- lib/quiz_api_client/services/courses_service.rb
|
209
182
|
- lib/quiz_api_client/services/interaction_types_service.rb
|
210
183
|
- lib/quiz_api_client/services/item_analyses_service.rb
|
211
184
|
- lib/quiz_api_client/services/items_service.rb
|
@@ -228,35 +201,13 @@ files:
|
|
228
201
|
- lib/quiz_api_client/services/shared_banks.rb
|
229
202
|
- lib/quiz_api_client/version.rb
|
230
203
|
- spec/config_spec.rb
|
231
|
-
- spec/contracts/interaction_types_service_spec.rb
|
232
|
-
- spec/contracts/item_analyses_service_spec.rb
|
233
|
-
- spec/contracts/items_service_spec.rb
|
234
|
-
- spec/contracts/qti_imports_service_spec.rb
|
235
|
-
- spec/contracts/quiz_clone_job_service_spec.rb
|
236
|
-
- spec/contracts/quiz_clone_jobs_service_spec.rb
|
237
|
-
- spec/contracts/quiz_entries_service_spec.rb
|
238
|
-
- spec/contracts/quiz_service_spec.rb
|
239
|
-
- spec/contracts/quiz_session_events_service_spec.rb
|
240
|
-
- spec/contracts/quiz_session_result_service_spec.rb
|
241
|
-
- spec/contracts/quiz_session_service_spec.rb
|
242
|
-
- spec/contracts/quiz_sessions_service_spec.rb
|
243
|
-
- spec/contracts/quiz_sync_job_service_spec.rb
|
244
|
-
- spec/contracts/quiz_sync_jobs_service_spec.rb
|
245
|
-
- spec/contracts/quizzes_service_spec.rb
|
246
|
-
- spec/contracts/session_item_results_service_spec.rb
|
247
|
-
- spec/contracts/session_items_service_spec.rb
|
248
|
-
- spec/contracts/shared_banks_spec.rb
|
249
|
-
- spec/contracts/shared_examples/http_delete_example.rb
|
250
|
-
- spec/contracts/shared_examples/http_get_example.rb
|
251
|
-
- spec/contracts/shared_examples/http_patch_example.rb
|
252
|
-
- spec/contracts/shared_examples/http_post_example.rb
|
253
|
-
- spec/contracts/shared_examples/http_put_example.rb
|
254
204
|
- spec/http_client_spec.rb
|
255
205
|
- spec/json_formatter_spec.rb
|
256
206
|
- spec/quiz_api_client/http_request/failure_spec.rb
|
257
207
|
- spec/quiz_api_client/http_request/metrics_spec.rb
|
258
208
|
- spec/quiz_api_client_spec.rb
|
259
209
|
- spec/services/base_api_service_spec.rb
|
210
|
+
- spec/services/courses_service_spec.rb
|
260
211
|
- spec/services/interaction_types_service_spec.rb
|
261
212
|
- spec/services/item_analyses_service_spec.rb
|
262
213
|
- spec/services/items_service_spec.rb
|
@@ -277,12 +228,10 @@ files:
|
|
277
228
|
- spec/services/session_item_results_service_spec.rb
|
278
229
|
- spec/services/session_items_service_spec.rb
|
279
230
|
- spec/spec_helper.rb
|
280
|
-
|
281
|
-
- spec/support/pact_helper.rb
|
282
|
-
homepage:
|
231
|
+
homepage:
|
283
232
|
licenses: []
|
284
233
|
metadata: {}
|
285
|
-
post_install_message:
|
234
|
+
post_install_message:
|
286
235
|
rdoc_options: []
|
287
236
|
require_paths:
|
288
237
|
- lib
|
@@ -297,41 +246,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
297
246
|
- !ruby/object:Gem::Version
|
298
247
|
version: '0'
|
299
248
|
requirements: []
|
300
|
-
rubygems_version: 3.1.
|
301
|
-
signing_key:
|
249
|
+
rubygems_version: 3.1.6
|
250
|
+
signing_key:
|
302
251
|
specification_version: 4
|
303
252
|
summary: Ruby client for quiz_api
|
304
253
|
test_files:
|
305
254
|
- spec/config_spec.rb
|
306
|
-
- spec/contracts/interaction_types_service_spec.rb
|
307
|
-
- spec/contracts/item_analyses_service_spec.rb
|
308
|
-
- spec/contracts/items_service_spec.rb
|
309
|
-
- spec/contracts/qti_imports_service_spec.rb
|
310
|
-
- spec/contracts/quiz_clone_job_service_spec.rb
|
311
|
-
- spec/contracts/quiz_clone_jobs_service_spec.rb
|
312
|
-
- spec/contracts/quiz_entries_service_spec.rb
|
313
|
-
- spec/contracts/quiz_service_spec.rb
|
314
|
-
- spec/contracts/quiz_session_events_service_spec.rb
|
315
|
-
- spec/contracts/quiz_session_result_service_spec.rb
|
316
|
-
- spec/contracts/quiz_session_service_spec.rb
|
317
|
-
- spec/contracts/quiz_sessions_service_spec.rb
|
318
|
-
- spec/contracts/quiz_sync_job_service_spec.rb
|
319
|
-
- spec/contracts/quiz_sync_jobs_service_spec.rb
|
320
|
-
- spec/contracts/quizzes_service_spec.rb
|
321
|
-
- spec/contracts/session_item_results_service_spec.rb
|
322
|
-
- spec/contracts/session_items_service_spec.rb
|
323
|
-
- spec/contracts/shared_banks_spec.rb
|
324
|
-
- spec/contracts/shared_examples/http_delete_example.rb
|
325
|
-
- spec/contracts/shared_examples/http_get_example.rb
|
326
|
-
- spec/contracts/shared_examples/http_patch_example.rb
|
327
|
-
- spec/contracts/shared_examples/http_post_example.rb
|
328
|
-
- spec/contracts/shared_examples/http_put_example.rb
|
329
255
|
- spec/http_client_spec.rb
|
330
256
|
- spec/json_formatter_spec.rb
|
331
257
|
- spec/quiz_api_client/http_request/failure_spec.rb
|
332
258
|
- spec/quiz_api_client/http_request/metrics_spec.rb
|
333
259
|
- spec/quiz_api_client_spec.rb
|
334
260
|
- spec/services/base_api_service_spec.rb
|
261
|
+
- spec/services/courses_service_spec.rb
|
335
262
|
- spec/services/interaction_types_service_spec.rb
|
336
263
|
- spec/services/item_analyses_service_spec.rb
|
337
264
|
- spec/services/items_service_spec.rb
|
@@ -352,5 +279,3 @@ test_files:
|
|
352
279
|
- spec/services/session_item_results_service_spec.rb
|
353
280
|
- spec/services/session_items_service_spec.rb
|
354
281
|
- spec/spec_helper.rb
|
355
|
-
- spec/support/pact_config.rb
|
356
|
-
- spec/support/pact_helper.rb
|
@@ -1,22 +0,0 @@
|
|
1
|
-
describe QuizApiClient::Services::InteractionTypesService, :pact do
|
2
|
-
include PactHelper
|
3
|
-
|
4
|
-
it_behaves_like 'a http get request to quiz_api collection endpoint' do
|
5
|
-
let(:provider_state) { 'a set of interaction types' }
|
6
|
-
let(:request_description) { 'a request to retrieve a list of interaction types' }
|
7
|
-
let(:quizzes_api_path) { '/api/interaction_types' }
|
8
|
-
let(:scope) { 'quiz.build' }
|
9
|
-
let(:params) { nil }
|
10
|
-
let(:response_body) do
|
11
|
-
Pact.each_like(
|
12
|
-
id: '1',
|
13
|
-
slug: 'choice',
|
14
|
-
name: 'Multiple Choice',
|
15
|
-
properties_schema: {},
|
16
|
-
scoring_algorithm_default: 'Equivalence',
|
17
|
-
user_response_type_options: ['Uuid']
|
18
|
-
)
|
19
|
-
end
|
20
|
-
let(:service_name) { :interaction_types_service }
|
21
|
-
end
|
22
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
describe QuizApiClient::Services::ItemAnalysesService, :pact do
|
2
|
-
include PactHelper
|
3
|
-
|
4
|
-
it_behaves_like 'a http get request to quiz_api collection endpoint', testrail_id: %w[3402546] do
|
5
|
-
let(:request_description) { 'a request to retrieve item analyses all quiz_id items' }
|
6
|
-
let(:quiz_id) { 1 }
|
7
|
-
let(:quizzes_api_path) { "/api/quizzes/#{quiz_id}/stats/item_analyses" }
|
8
|
-
let(:provider_state) { 'quiz with item analysis' }
|
9
|
-
let(:resource_id) { '1' }
|
10
|
-
let(:scope) { 'quiz.analysis' }
|
11
|
-
let(:params) { { quiz_id: '1' } }
|
12
|
-
let(:response_body) do
|
13
|
-
[
|
14
|
-
{
|
15
|
-
item_id: Pact.like('1'),
|
16
|
-
points_possible: Pact.like(1.0),
|
17
|
-
item_body: Pact.like('item body'),
|
18
|
-
interaction_type: 'choice',
|
19
|
-
item_analysis: {},
|
20
|
-
batch_timestamp: Pact.like('2017-06-15T22:14:51.215Z'),
|
21
|
-
outcome_alignment_set_guid: Pact.like('cbedd9b0-d1ab-43a9-a3b2-89c3134a722a')
|
22
|
-
},
|
23
|
-
{
|
24
|
-
item_id: Pact.like('1'),
|
25
|
-
points_possible: Pact.like(1.0),
|
26
|
-
item_body: Pact.like('item body'),
|
27
|
-
interaction_type: 'choice',
|
28
|
-
item_analysis: {},
|
29
|
-
batch_timestamp: Pact.like('2017-06-15T22:14:51.215Z'),
|
30
|
-
outcome_alignment_set_guid: Pact.like('cbedd9b0-d1ab-43a9-a3b2-89c3134a722a')
|
31
|
-
}
|
32
|
-
]
|
33
|
-
end
|
34
|
-
let(:service_name) { :item_analyses_service }
|
35
|
-
end
|
36
|
-
|
37
|
-
it_behaves_like 'a http get only request to quiz_api', testrail_id: %w[3402547] do
|
38
|
-
let(:request_description) { 'a request to retrieve item analyses for a quiz item' }
|
39
|
-
let(:quiz_id) { 1 }
|
40
|
-
let(:id) { 1 }
|
41
|
-
let(:quizzes_api_path) { "/api/quizzes/#{quiz_id}/stats/item_analyses/#{id}" }
|
42
|
-
let(:provider_state) { 'quiz with item analysis' }
|
43
|
-
let(:resource_id) { '1' }
|
44
|
-
let(:scope) { 'quiz.analysis' }
|
45
|
-
let(:params) { { quiz_id: '1', id: '1' } }
|
46
|
-
let(:response_body) do
|
47
|
-
{
|
48
|
-
item_id: Pact.like('1'),
|
49
|
-
points_possible: Pact.like(1.0),
|
50
|
-
item_body: Pact.like('item body'),
|
51
|
-
interaction_type: 'choice',
|
52
|
-
item_analysis: {},
|
53
|
-
batch_timestamp: Pact.like('2017-06-15T22:14:51.215Z'),
|
54
|
-
outcome_alignment_set_guid: Pact.like('cbedd9b0-d1ab-43a9-a3b2-89c3134a722a')
|
55
|
-
}
|
56
|
-
end
|
57
|
-
let(:service_name) { :item_analyses_service }
|
58
|
-
end
|
59
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
describe QuizApiClient::Services::ItemsService, :pact do
|
2
|
-
include PactHelper
|
3
|
-
|
4
|
-
it_behaves_like 'a http post request to quiz_api' do
|
5
|
-
let(:provider_state) { 'a quiz and a multiple choice interaction type' }
|
6
|
-
let(:request_description) { 'a request to create an item' }
|
7
|
-
let(:quizzes_api_path) { "/api/quizzes/#{quiz_id}/items" }
|
8
|
-
let(:resource_id) { '1' }
|
9
|
-
let(:scope) { 'quiz.build' }
|
10
|
-
let(:quiz_id) { 1 }
|
11
|
-
let(:params) do
|
12
|
-
{
|
13
|
-
quiz_id: quiz_id,
|
14
|
-
interaction_data: {
|
15
|
-
choices: [{
|
16
|
-
id: 'guid',
|
17
|
-
itemBody: '<p>Choice</p>',
|
18
|
-
position: 1
|
19
|
-
}]
|
20
|
-
},
|
21
|
-
interaction_type_id: 1, # we'll seed InteractionType::MultipleChoice
|
22
|
-
item_body: 'Some kind of stem',
|
23
|
-
properties: {},
|
24
|
-
scoring_algorithm: 'Equivalence',
|
25
|
-
scoring_data: {
|
26
|
-
value: 'another guid'
|
27
|
-
},
|
28
|
-
title: 'A perfectly cromulent title',
|
29
|
-
user_response_type: 'Uuid'
|
30
|
-
}
|
31
|
-
end
|
32
|
-
let(:item_params) { params.clone.tap { |p| p.delete(:quiz_id) } }
|
33
|
-
let(:body) { { quiz_id: quiz_id, item: item_params } }
|
34
|
-
let(:response_body) do
|
35
|
-
{
|
36
|
-
id: Pact.like('1'),
|
37
|
-
interaction_data: {
|
38
|
-
choices: Pact.each_like(
|
39
|
-
id: 'a guid',
|
40
|
-
item_body: 'choice description',
|
41
|
-
position: 1
|
42
|
-
)
|
43
|
-
},
|
44
|
-
item_body: Pact.like(''),
|
45
|
-
properties: Pact.like({}),
|
46
|
-
status: Pact.like(''),
|
47
|
-
title: Pact.like(''),
|
48
|
-
user_response_type: Pact.like(''),
|
49
|
-
stimulus_id: Pact.like(''),
|
50
|
-
interaction_type: Pact.like({}),
|
51
|
-
scoring_data: {
|
52
|
-
value: Pact.like('')
|
53
|
-
},
|
54
|
-
scoring_algorithm: Pact.like('')
|
55
|
-
}
|
56
|
-
end
|
57
|
-
let(:service_name) { :items_service }
|
58
|
-
end
|
59
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
describe QuizApiClient::Services::QtiImportsService, :pact do
|
2
|
-
include PactHelper
|
3
|
-
|
4
|
-
it_behaves_like 'a http post request to quiz_api', testrail_id: %w[3402548] do
|
5
|
-
let(:request_description) { 'a request to import a QTI' }
|
6
|
-
let(:provider_state) { 'a quiz' }
|
7
|
-
let(:quiz_id) { 1 }
|
8
|
-
let(:url) { 'http://fake.url' }
|
9
|
-
let(:quizzes_api_path) { "/api/quizzes/#{quiz_id}/qti_imports" }
|
10
|
-
let(:scope) { 'qti_import.create' }
|
11
|
-
let(:resource_id) { quiz_id }
|
12
|
-
let(:params) do
|
13
|
-
{
|
14
|
-
quiz_id: quiz_id,
|
15
|
-
url: url
|
16
|
-
}
|
17
|
-
end
|
18
|
-
let(:body) { { qti_import: params } }
|
19
|
-
let(:response_body) do
|
20
|
-
{
|
21
|
-
id: Pact.like('1'),
|
22
|
-
parent_id: quiz_id.to_s,
|
23
|
-
parent_type: Pact.like('Quiz'),
|
24
|
-
status: 'scheduled',
|
25
|
-
url: url,
|
26
|
-
message: Pact.like(''),
|
27
|
-
created_at: Pact.like(''),
|
28
|
-
updated_at: Pact.like(''),
|
29
|
-
progress: Pact.like(0.0)
|
30
|
-
}
|
31
|
-
end
|
32
|
-
let(:service_name) { :qti_imports_service }
|
33
|
-
end
|
34
|
-
end
|