openstax_exchange 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/.travis.yml +3 -1
- data/exchange-client.gemspec +1 -0
- data/lib/openstax/exchange/exchange.rb +4 -4
- data/lib/openstax/exchange/fake_client/fake_client.rb +11 -10
- data/lib/openstax/exchange/real_client/real_client.rb +14 -4
- data/lib/openstax/exchange/version.rb +1 -1
- data/spec/cassettes/OpenStax_Exchange_RealClient/behaves_like_exchange_client_api_v1/{_create_identifier → _create_identifiers}/success/creates_and_returns_a_new_identifier.yml +27 -20
- data/spec/cassettes/OpenStax_Exchange_RealClient/behaves_like_exchange_client_api_v1/{_create_identifier/success/creates_a_distinct_identifer_per_invokation.yml → _create_identifiers/success/creates_distinct_identifiers_per_invokation.yml} +42 -31
- data/spec/cassettes/OpenStax_Exchange_RealClient/behaves_like_exchange_client_api_v1/_record_multiple_choice_answer/duplicate_identifer_resource_trial_triplet/{raises_an_exception.yml → records_the_new_answer.yml} +44 -40
- data/spec/cassettes/OpenStax_Exchange_RealClient/behaves_like_exchange_client_api_v1/_record_multiple_choice_answer/invalid_resource_string/raises_an_exception.yml +40 -31
- data/spec/cassettes/OpenStax_Exchange_RealClient/behaves_like_exchange_client_api_v1/_record_multiple_choice_answer/success/allows_answers_with_distinct_identifiers_to_be_saved.yml +70 -55
- data/spec/cassettes/OpenStax_Exchange_RealClient/behaves_like_exchange_client_api_v1/_record_multiple_choice_answer/success/allows_answers_with_distinct_resources_to_be_saved.yml +55 -44
- data/spec/cassettes/OpenStax_Exchange_RealClient/behaves_like_exchange_client_api_v1/_record_multiple_choice_answer/success/allows_answers_with_distinct_trials_to_be_saved.yml +55 -44
- data/spec/cassettes/OpenStax_Exchange_RealClient/behaves_like_exchange_client_api_v1/_record_multiple_choice_answer/success/creates_a_multiple_choice_answer_associated_with_the_given_identifier.yml +41 -32
- data/spec/lib/openstax/exchange/shared_examples_for_exchange_client_v1.rb +40 -24
- metadata +26 -10
@@ -4,15 +4,17 @@ http_interactions:
|
|
4
4
|
method: post
|
5
5
|
uri: http://123:abc@localhost:3003/oauth/token
|
6
6
|
body:
|
7
|
-
encoding:
|
7
|
+
encoding: UTF-8
|
8
8
|
string: grant_type=client_credentials
|
9
9
|
headers:
|
10
10
|
User-Agent:
|
11
|
-
- Faraday v0.9.
|
11
|
+
- Faraday v0.9.1
|
12
12
|
Content-Type:
|
13
13
|
- application/x-www-form-urlencoded
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
14
16
|
Accept:
|
15
|
-
-
|
17
|
+
- "*/*"
|
16
18
|
response:
|
17
19
|
status:
|
18
20
|
code: 200
|
@@ -31,35 +33,40 @@ http_interactions:
|
|
31
33
|
Content-Type:
|
32
34
|
- application/json; charset=utf-8
|
33
35
|
Etag:
|
34
|
-
- W/"
|
36
|
+
- W/"01a3dc6120131867d799eeb81ededd7c"
|
35
37
|
X-Request-Id:
|
36
|
-
-
|
38
|
+
- 50b8abb8-2581-4563-9fb3-b2c8aaaf110c
|
37
39
|
X-Runtime:
|
38
|
-
- '0.
|
40
|
+
- '0.016761'
|
39
41
|
Connection:
|
40
42
|
- close
|
41
43
|
Server:
|
42
44
|
- thin
|
43
45
|
body:
|
44
|
-
encoding:
|
45
|
-
string:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: '{"access_token":"63f9dbd18dbdb22c5edf9c16a89754405d388e9185639d748590edac6e94b640","token_type":"bearer","scope":"read
|
48
|
+
write","created_at":1430246610}'
|
46
49
|
http_version:
|
47
|
-
recorded_at:
|
50
|
+
recorded_at: Tue, 28 Apr 2015 18:43:30 GMT
|
48
51
|
- request:
|
49
52
|
method: post
|
50
53
|
uri: http://localhost:3003/api/identifiers
|
51
54
|
body:
|
52
|
-
encoding:
|
55
|
+
encoding: UTF-8
|
53
56
|
string: ''
|
54
57
|
headers:
|
55
58
|
User-Agent:
|
56
|
-
- Faraday v0.9.
|
59
|
+
- Faraday v0.9.1
|
57
60
|
Accept:
|
58
61
|
- application/vnd.exchange.openstax.v1
|
62
|
+
Content-Type:
|
63
|
+
- application/json
|
59
64
|
Authorization:
|
60
|
-
- Bearer
|
65
|
+
- Bearer 63f9dbd18dbdb22c5edf9c16a89754405d388e9185639d748590edac6e94b640
|
61
66
|
Content-Length:
|
62
67
|
- '0'
|
68
|
+
Accept-Encoding:
|
69
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
63
70
|
response:
|
64
71
|
status:
|
65
72
|
code: 201
|
@@ -71,44 +78,46 @@ http_interactions:
|
|
71
78
|
- 1; mode=block
|
72
79
|
X-Content-Type-Options:
|
73
80
|
- nosniff
|
81
|
+
Date:
|
82
|
+
- Tue, 28 Apr 2015 18:43:30 GMT
|
74
83
|
Content-Type:
|
75
84
|
- application/json; charset=utf-8
|
76
85
|
Etag:
|
77
|
-
- W/"
|
86
|
+
- W/"4ce5b4a127b4a8b4217b22febac168e2"
|
78
87
|
Cache-Control:
|
79
88
|
- max-age=0, private, must-revalidate
|
80
89
|
Set-Cookie:
|
81
|
-
- _exercises_session=MXhFZHZROXBOL0htVUZURkN6c1EvVkl4emF4WjlCcEpEeld6R21CVWlmZVltWUt1ODZ0cnh6WVl2d3Jka0dIOVVEdStRbXFGZ0pxUCtHTmhzUllZTkE9PS0taGNnRlhPTU9VMWNwTzM3a2ZjK2x1dz09--96afdd88799321242558c51063c5740eb5628341;
|
82
|
-
path=/; HttpOnly
|
83
90
|
- request_method=POST; path=/
|
84
91
|
X-Request-Id:
|
85
|
-
-
|
92
|
+
- db6a9b5f-7fb9-46f4-adaf-f89eb9db4c20
|
86
93
|
X-Runtime:
|
87
|
-
- '0.
|
94
|
+
- '0.055572'
|
88
95
|
Connection:
|
89
96
|
- close
|
90
97
|
Server:
|
91
98
|
- thin
|
92
99
|
body:
|
93
|
-
encoding:
|
94
|
-
string:
|
100
|
+
encoding: UTF-8
|
101
|
+
string: '{"read":"18252758189f85fb48d2a5536d5f09630a72e321dffa89223067aa02efc542ab","write":"697ed8df8b11bf5efe110c397c838b4f09ad88fb0997cff4ff512d8249d5f662"}'
|
95
102
|
http_version:
|
96
|
-
recorded_at:
|
103
|
+
recorded_at: Tue, 28 Apr 2015 18:43:30 GMT
|
97
104
|
- request:
|
98
105
|
method: post
|
99
106
|
uri: http://localhost:3003/api/events/platforms/multiple_choices
|
100
107
|
body:
|
101
108
|
encoding: UTF-8
|
102
|
-
string:
|
109
|
+
string: '{"identifier":"697ed8df8b11bf5efe110c397c838b4f09ad88fb0997cff4ff512d8249d5f662","resource":"https://exercises-dev1.openstax.org/api/exercises/123@1","trial":"1","answer":"answer_string"}'
|
103
110
|
headers:
|
104
111
|
User-Agent:
|
105
|
-
- Faraday v0.9.
|
112
|
+
- Faraday v0.9.1
|
106
113
|
Accept:
|
107
114
|
- application/vnd.exchange.openstax.v1
|
108
115
|
Authorization:
|
109
|
-
- Bearer
|
116
|
+
- Bearer 63f9dbd18dbdb22c5edf9c16a89754405d388e9185639d748590edac6e94b640
|
110
117
|
Content-Type:
|
111
|
-
- application/
|
118
|
+
- application/json
|
119
|
+
Accept-Encoding:
|
120
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
112
121
|
response:
|
113
122
|
status:
|
114
123
|
code: 201
|
@@ -120,44 +129,46 @@ http_interactions:
|
|
120
129
|
- 1; mode=block
|
121
130
|
X-Content-Type-Options:
|
122
131
|
- nosniff
|
132
|
+
Date:
|
133
|
+
- Tue, 28 Apr 2015 18:43:30 GMT
|
123
134
|
Content-Type:
|
124
135
|
- application/json; charset=utf-8
|
125
136
|
Etag:
|
126
|
-
- W/"
|
137
|
+
- W/"8a8ac413619079b24604116af205df89"
|
127
138
|
Cache-Control:
|
128
139
|
- max-age=0, private, must-revalidate
|
129
140
|
Set-Cookie:
|
130
|
-
- _exercises_session=NTJxQU1LM3VLRmJZYmZveHl5RFkxWkorVWNxMUZYQWpuNWx3OVZrbFlDT0tVYWhucXpMTXZ2SXY2SUdXVStxZ0VzZlJNYTg5ckIzaVdiWC92dy95V0E9PS0tK1hLVWRzRDA4MzRhWWhBbUEwenRuUT09--5629f468e0c0390f0e8503de735c2de2bb61fdb8;
|
131
|
-
path=/; HttpOnly
|
132
141
|
- request_method=POST; path=/
|
133
142
|
X-Request-Id:
|
134
|
-
-
|
143
|
+
- bec18dd1-93e3-4d47-934b-81be11d63a92
|
135
144
|
X-Runtime:
|
136
|
-
- '0.
|
145
|
+
- '0.077400'
|
137
146
|
Connection:
|
138
147
|
- close
|
139
148
|
Server:
|
140
149
|
- thin
|
141
150
|
body:
|
142
|
-
encoding:
|
143
|
-
string:
|
151
|
+
encoding: UTF-8
|
152
|
+
string: '{"identifier":"697ed8df8b11bf5efe110c397c838b4f09ad88fb0997cff4ff512d8249d5f662","resource":"https://exercises-dev1.openstax.org/api/exercises/123@1","trial":"1","created_at":"2015-04-28T18:43:30.206Z","answer_type":"multiple-choice","answer":"answer_string"}'
|
144
153
|
http_version:
|
145
|
-
recorded_at:
|
154
|
+
recorded_at: Tue, 28 Apr 2015 18:43:30 GMT
|
146
155
|
- request:
|
147
156
|
method: post
|
148
157
|
uri: http://localhost:3003/api/events/platforms/multiple_choices
|
149
158
|
body:
|
150
159
|
encoding: UTF-8
|
151
|
-
string:
|
160
|
+
string: '{"identifier":"697ed8df8b11bf5efe110c397c838b4f09ad88fb0997cff4ff512d8249d5f662","resource":"https://exercises-dev1.openstax.org/api/exercises/123@1","trial":"2","answer":"answer_string"}'
|
152
161
|
headers:
|
153
162
|
User-Agent:
|
154
|
-
- Faraday v0.9.
|
163
|
+
- Faraday v0.9.1
|
155
164
|
Accept:
|
156
165
|
- application/vnd.exchange.openstax.v1
|
157
166
|
Authorization:
|
158
|
-
- Bearer
|
167
|
+
- Bearer 63f9dbd18dbdb22c5edf9c16a89754405d388e9185639d748590edac6e94b640
|
159
168
|
Content-Type:
|
160
|
-
- application/
|
169
|
+
- application/json
|
170
|
+
Accept-Encoding:
|
171
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
161
172
|
response:
|
162
173
|
status:
|
163
174
|
code: 201
|
@@ -169,27 +180,27 @@ http_interactions:
|
|
169
180
|
- 1; mode=block
|
170
181
|
X-Content-Type-Options:
|
171
182
|
- nosniff
|
183
|
+
Date:
|
184
|
+
- Tue, 28 Apr 2015 18:43:30 GMT
|
172
185
|
Content-Type:
|
173
186
|
- application/json; charset=utf-8
|
174
187
|
Etag:
|
175
|
-
- W/"
|
188
|
+
- W/"c72abbf5393222af122d2d4811ff78da"
|
176
189
|
Cache-Control:
|
177
190
|
- max-age=0, private, must-revalidate
|
178
191
|
Set-Cookie:
|
179
|
-
- _exercises_session=TUd2eDhvNUVSdjVTaXFrQUdXRTVBYUlqdE40UnV0N0ptZXc0SXBYV3BWaW54VVJ4Tzh4RFk5K3ZMUzhIbS9Pd1VoS2N6aWZWeVN6Y0NkRERkMFBwMUE9PS0tbEh6cnlaMUZiSU43Qmx4QXlxeFdOdz09--158b91791d386dbb96fbf65af3db126c7cd9b8f0;
|
180
|
-
path=/; HttpOnly
|
181
192
|
- request_method=POST; path=/
|
182
193
|
X-Request-Id:
|
183
|
-
-
|
194
|
+
- b9796968-8924-47e3-bf69-52571db62d1e
|
184
195
|
X-Runtime:
|
185
|
-
- '0.
|
196
|
+
- '0.088069'
|
186
197
|
Connection:
|
187
198
|
- close
|
188
199
|
Server:
|
189
200
|
- thin
|
190
201
|
body:
|
191
|
-
encoding:
|
192
|
-
string:
|
202
|
+
encoding: UTF-8
|
203
|
+
string: '{"identifier":"697ed8df8b11bf5efe110c397c838b4f09ad88fb0997cff4ff512d8249d5f662","resource":"https://exercises-dev1.openstax.org/api/exercises/123@1","trial":"2","created_at":"2015-04-28T18:43:30.298Z","answer_type":"multiple-choice","answer":"answer_string"}'
|
193
204
|
http_version:
|
194
|
-
recorded_at:
|
205
|
+
recorded_at: Tue, 28 Apr 2015 18:43:30 GMT
|
195
206
|
recorded_with: VCR 2.9.3
|
@@ -4,15 +4,17 @@ http_interactions:
|
|
4
4
|
method: post
|
5
5
|
uri: http://123:abc@localhost:3003/oauth/token
|
6
6
|
body:
|
7
|
-
encoding:
|
7
|
+
encoding: UTF-8
|
8
8
|
string: grant_type=client_credentials
|
9
9
|
headers:
|
10
10
|
User-Agent:
|
11
|
-
- Faraday v0.9.
|
11
|
+
- Faraday v0.9.1
|
12
12
|
Content-Type:
|
13
13
|
- application/x-www-form-urlencoded
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
14
16
|
Accept:
|
15
|
-
-
|
17
|
+
- "*/*"
|
16
18
|
response:
|
17
19
|
status:
|
18
20
|
code: 200
|
@@ -31,35 +33,40 @@ http_interactions:
|
|
31
33
|
Content-Type:
|
32
34
|
- application/json; charset=utf-8
|
33
35
|
Etag:
|
34
|
-
- W/"
|
36
|
+
- W/"815cacdcae868316d9283b4c4234be07"
|
35
37
|
X-Request-Id:
|
36
|
-
-
|
38
|
+
- 8ff577cb-4792-454d-aaa8-d18229200ca4
|
37
39
|
X-Runtime:
|
38
|
-
- '0.
|
40
|
+
- '0.015656'
|
39
41
|
Connection:
|
40
42
|
- close
|
41
43
|
Server:
|
42
44
|
- thin
|
43
45
|
body:
|
44
|
-
encoding:
|
45
|
-
string:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: '{"access_token":"5552d62289d2c8e4ccbc676e1624dbf145da58cbce820e76dd004ecbddfd8078","token_type":"bearer","scope":"read
|
48
|
+
write","created_at":1430246609}'
|
46
49
|
http_version:
|
47
|
-
recorded_at:
|
50
|
+
recorded_at: Tue, 28 Apr 2015 18:43:29 GMT
|
48
51
|
- request:
|
49
52
|
method: post
|
50
53
|
uri: http://localhost:3003/api/identifiers
|
51
54
|
body:
|
52
|
-
encoding:
|
55
|
+
encoding: UTF-8
|
53
56
|
string: ''
|
54
57
|
headers:
|
55
58
|
User-Agent:
|
56
|
-
- Faraday v0.9.
|
59
|
+
- Faraday v0.9.1
|
57
60
|
Accept:
|
58
61
|
- application/vnd.exchange.openstax.v1
|
62
|
+
Content-Type:
|
63
|
+
- application/json
|
59
64
|
Authorization:
|
60
|
-
- Bearer
|
65
|
+
- Bearer 5552d62289d2c8e4ccbc676e1624dbf145da58cbce820e76dd004ecbddfd8078
|
61
66
|
Content-Length:
|
62
67
|
- '0'
|
68
|
+
Accept-Encoding:
|
69
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
63
70
|
response:
|
64
71
|
status:
|
65
72
|
code: 201
|
@@ -71,44 +78,46 @@ http_interactions:
|
|
71
78
|
- 1; mode=block
|
72
79
|
X-Content-Type-Options:
|
73
80
|
- nosniff
|
81
|
+
Date:
|
82
|
+
- Tue, 28 Apr 2015 18:43:29 GMT
|
74
83
|
Content-Type:
|
75
84
|
- application/json; charset=utf-8
|
76
85
|
Etag:
|
77
|
-
- W/"
|
86
|
+
- W/"fe30d78c0c6dfa5d263ef6f2f272ef41"
|
78
87
|
Cache-Control:
|
79
88
|
- max-age=0, private, must-revalidate
|
80
89
|
Set-Cookie:
|
81
|
-
- _exercises_session=Y0FCSkN1L21TRkp0S2xJNkxuRGJUZkdNSjJML3F5NVRsdmd4WUlqaTdiczZ2WDRXcE1MTDFhVFFHRmxzL1R5Y0pHRlpRTzJYRzNKSmxnUzZIUFlHR1E9PS0tVFRkTkdBWk9YaGw3Q1A4M29NWmxiUT09--a105cf2f6eb8f7307466b070661c139095608ea5;
|
82
|
-
path=/; HttpOnly
|
83
90
|
- request_method=POST; path=/
|
84
91
|
X-Request-Id:
|
85
|
-
-
|
92
|
+
- b063040f-9657-4688-b184-13598fdfaaa5
|
86
93
|
X-Runtime:
|
87
|
-
- '0.
|
94
|
+
- '0.055653'
|
88
95
|
Connection:
|
89
96
|
- close
|
90
97
|
Server:
|
91
98
|
- thin
|
92
99
|
body:
|
93
|
-
encoding:
|
94
|
-
string:
|
100
|
+
encoding: UTF-8
|
101
|
+
string: '{"read":"029aa6a1917fdad644ffecbf6a65a670700e24c91bd7382009308ef5e48791b2","write":"c7a0b2e50c5cb79da5dc9f7d0794ef45189f2077e3eac7df23cb3914a78ced9c"}'
|
95
102
|
http_version:
|
96
|
-
recorded_at:
|
103
|
+
recorded_at: Tue, 28 Apr 2015 18:43:29 GMT
|
97
104
|
- request:
|
98
105
|
method: post
|
99
106
|
uri: http://localhost:3003/api/events/platforms/multiple_choices
|
100
107
|
body:
|
101
108
|
encoding: UTF-8
|
102
|
-
string:
|
109
|
+
string: '{"identifier":"c7a0b2e50c5cb79da5dc9f7d0794ef45189f2077e3eac7df23cb3914a78ced9c","resource":"https://exercises-dev1.openstax.org/api/exercises/123@1","trial":"1","answer":"answer_string"}'
|
103
110
|
headers:
|
104
111
|
User-Agent:
|
105
|
-
- Faraday v0.9.
|
112
|
+
- Faraday v0.9.1
|
106
113
|
Accept:
|
107
114
|
- application/vnd.exchange.openstax.v1
|
108
115
|
Authorization:
|
109
|
-
- Bearer
|
116
|
+
- Bearer 5552d62289d2c8e4ccbc676e1624dbf145da58cbce820e76dd004ecbddfd8078
|
110
117
|
Content-Type:
|
111
|
-
- application/
|
118
|
+
- application/json
|
119
|
+
Accept-Encoding:
|
120
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
112
121
|
response:
|
113
122
|
status:
|
114
123
|
code: 201
|
@@ -120,27 +129,27 @@ http_interactions:
|
|
120
129
|
- 1; mode=block
|
121
130
|
X-Content-Type-Options:
|
122
131
|
- nosniff
|
132
|
+
Date:
|
133
|
+
- Tue, 28 Apr 2015 18:43:29 GMT
|
123
134
|
Content-Type:
|
124
135
|
- application/json; charset=utf-8
|
125
136
|
Etag:
|
126
|
-
- W/"
|
137
|
+
- W/"caf97912c3657c4d0bbaab554f64e444"
|
127
138
|
Cache-Control:
|
128
139
|
- max-age=0, private, must-revalidate
|
129
140
|
Set-Cookie:
|
130
|
-
- _exercises_session=RUdNUXpxRkR1YzRlcE05MFJKV3NRQnJIaUU4RzhHTW9pREtzWUd2TjRiMGdZM2RsZlhmaHZKdlJ1dDRRRi9GUVlkZUo2anBFbkw5ZjErdU1Sb3Q1VVE9PS0tb3NIaTJoQ3djbkpzaWZhU0dkQ3hXUT09--b863b16466f2fc8176a22fa602c21184415f14ed;
|
131
|
-
path=/; HttpOnly
|
132
141
|
- request_method=POST; path=/
|
133
142
|
X-Request-Id:
|
134
|
-
-
|
143
|
+
- 7c475370-105f-47ce-845e-9f991408395a
|
135
144
|
X-Runtime:
|
136
|
-
- '0.
|
145
|
+
- '0.074384'
|
137
146
|
Connection:
|
138
147
|
- close
|
139
148
|
Server:
|
140
149
|
- thin
|
141
150
|
body:
|
142
|
-
encoding:
|
143
|
-
string:
|
151
|
+
encoding: UTF-8
|
152
|
+
string: '{"identifier":"c7a0b2e50c5cb79da5dc9f7d0794ef45189f2077e3eac7df23cb3914a78ced9c","resource":"https://exercises-dev1.openstax.org/api/exercises/123@1","trial":"1","created_at":"2015-04-28T18:43:29.466Z","answer_type":"multiple-choice","answer":"answer_string"}'
|
144
153
|
http_version:
|
145
|
-
recorded_at:
|
154
|
+
recorded_at: Tue, 28 Apr 2015 18:43:29 GMT
|
146
155
|
recorded_with: VCR 2.9.3
|
@@ -61,16 +61,29 @@ RSpec.shared_examples "exchange client api v1" do
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
describe "#
|
64
|
+
describe "#create_identifiers" do
|
65
65
|
context "success" do
|
66
66
|
it "creates and returns a new identifier" do
|
67
|
-
|
68
|
-
|
67
|
+
response = OpenStax::Exchange.create_identifiers
|
68
|
+
read_identifier = response.read
|
69
|
+
write_identifier = response.write
|
70
|
+
expect(read_identifier).to match(/^[a-fA-F0-9]+$/)
|
71
|
+
expect(write_identifier).to match(/^[a-fA-F0-9]+$/)
|
69
72
|
end
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
+
|
74
|
+
it "creates distinct identifiers per invokation" do
|
75
|
+
response1 = OpenStax::Exchange.create_identifiers
|
76
|
+
response2 = OpenStax::Exchange.create_identifiers
|
77
|
+
identifier1 = response1.read
|
78
|
+
identifier2 = response1.write
|
79
|
+
identifier3 = response2.read
|
80
|
+
identifier4 = response2.write
|
73
81
|
expect(identifier1).to_not eq(identifier2)
|
82
|
+
expect(identifier1).to_not eq(identifier3)
|
83
|
+
expect(identifier1).to_not eq(identifier4)
|
84
|
+
expect(identifier2).to_not eq(identifier3)
|
85
|
+
expect(identifier2).to_not eq(identifier4)
|
86
|
+
expect(identifier3).to_not eq(identifier4)
|
74
87
|
end
|
75
88
|
end
|
76
89
|
end
|
@@ -78,11 +91,11 @@ RSpec.shared_examples "exchange client api v1" do
|
|
78
91
|
describe "#record_multiple_choice_answer" do
|
79
92
|
context "success" do
|
80
93
|
it "creates a multiple choice answer associated with the given identifier" do
|
81
|
-
identifier = OpenStax::Exchange.
|
94
|
+
identifier = OpenStax::Exchange.create_identifiers.write
|
82
95
|
|
83
96
|
# must have the form of a "trusted resource"
|
84
97
|
# (Exchange app/routines/find_or_create_resource_from_url.rb:35)
|
85
|
-
resource_string = '
|
98
|
+
resource_string = 'https://exercises-dev1.openstax.org/api/exercises/123@1'
|
86
99
|
trial = '1'
|
87
100
|
answer_string = 'answer_string'
|
88
101
|
|
@@ -95,12 +108,12 @@ RSpec.shared_examples "exchange client api v1" do
|
|
95
108
|
expect(response['answer']).to eq(answer_string)
|
96
109
|
end
|
97
110
|
it "allows answers with distinct identifiers to be saved" do
|
98
|
-
identifier1 = OpenStax::Exchange.
|
99
|
-
identifier2 = OpenStax::Exchange.
|
111
|
+
identifier1 = OpenStax::Exchange.create_identifiers.write
|
112
|
+
identifier2 = OpenStax::Exchange.create_identifiers.write
|
100
113
|
|
101
114
|
# must have the form of a "trusted resource"
|
102
115
|
# (Exchange app/routines/find_or_create_resource_from_url.rb:35)
|
103
|
-
resource_string = '
|
116
|
+
resource_string = 'https://exercises-dev1.openstax.org/api/exercises/123@1'
|
104
117
|
trial = '1'
|
105
118
|
answer_string = 'answer_string'
|
106
119
|
|
@@ -119,12 +132,12 @@ RSpec.shared_examples "exchange client api v1" do
|
|
119
132
|
expect(response['identifier']).to eq(identifier2)
|
120
133
|
end
|
121
134
|
it "allows answers with distinct resources to be saved" do
|
122
|
-
identifier = OpenStax::Exchange.
|
135
|
+
identifier = OpenStax::Exchange.create_identifiers.write
|
123
136
|
|
124
137
|
# must have the form of a "trusted resource"
|
125
138
|
# (Exchange app/routines/find_or_create_resource_from_url.rb:35)
|
126
|
-
resource_string1 = '
|
127
|
-
resource_string2 = '
|
139
|
+
resource_string1 = 'https://exercises-dev1.openstax.org/api/exercises/12@1'
|
140
|
+
resource_string2 = 'https://exercises-dev1.openstax.org/api/exercises/123@1'
|
128
141
|
trial = '1'
|
129
142
|
answer_string = 'answer_string'
|
130
143
|
|
@@ -143,11 +156,11 @@ RSpec.shared_examples "exchange client api v1" do
|
|
143
156
|
expect(response['resource']).to eq(resource_string2)
|
144
157
|
end
|
145
158
|
it "allows answers with distinct trials to be saved" do
|
146
|
-
identifier = OpenStax::Exchange.
|
159
|
+
identifier = OpenStax::Exchange.create_identifiers.write
|
147
160
|
|
148
161
|
# must have the form of a "trusted resource"
|
149
162
|
# (Exchange app/routines/find_or_create_resource_from_url.rb:35)
|
150
|
-
resource_string = '
|
163
|
+
resource_string = 'https://exercises-dev1.openstax.org/api/exercises/123@1'
|
151
164
|
trial1 = '1'
|
152
165
|
trial2 = '2'
|
153
166
|
answer_string = 'answer_string'
|
@@ -168,33 +181,36 @@ RSpec.shared_examples "exchange client api v1" do
|
|
168
181
|
end
|
169
182
|
end
|
170
183
|
context "duplicate (identifer,resource,trial) triplet" do
|
171
|
-
it "
|
172
|
-
identifier = OpenStax::Exchange.
|
184
|
+
it "records the new answer" do
|
185
|
+
identifier = OpenStax::Exchange.create_identifiers.write
|
173
186
|
|
174
187
|
# must have the form of a "trusted resource"
|
175
188
|
# (Exchange app/routines/find_or_create_resource_from_url.rb:35)
|
176
|
-
resource_string = '
|
189
|
+
resource_string = 'https://exercises-dev1.openstax.org/api/exercises/123@1'
|
177
190
|
trial = '1'
|
178
191
|
answer_string = 'answer_string'
|
192
|
+
answer_string_2 = 'another_string'
|
179
193
|
|
180
194
|
expect {
|
181
195
|
response = OpenStax::Exchange.record_multiple_choice_answer(
|
182
|
-
identifier, resource_string, trial, answer_string
|
196
|
+
identifier, resource_string, trial, answer_string
|
197
|
+
)
|
183
198
|
}.to_not raise_error
|
184
199
|
|
185
200
|
expect {
|
186
201
|
response = OpenStax::Exchange.record_multiple_choice_answer(
|
187
|
-
identifier, resource_string, trial,
|
188
|
-
|
202
|
+
identifier, resource_string, trial, answer_string_2
|
203
|
+
)
|
204
|
+
}.to_not raise_error
|
189
205
|
end
|
190
206
|
end
|
191
207
|
context "invalid resource string" do
|
192
208
|
it "raises an exception" do
|
193
|
-
identifier = OpenStax::Exchange.
|
209
|
+
identifier = OpenStax::Exchange.create_identifiers.write
|
194
210
|
|
195
211
|
# must have the form of a "trusted resource"
|
196
212
|
# (Exchange app/routines/find_or_create_resource_from_url.rb:35)
|
197
|
-
resource_string = '
|
213
|
+
resource_string = 'https://example.com/api/exercises/123@1'
|
198
214
|
trial = '1'
|
199
215
|
answer_string = 'answer_string'
|
200
216
|
|