raml_ruby 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -0
  3. data/README.md +1 -9
  4. data/Rakefile +7 -0
  5. data/lib/raml.rb +6 -26
  6. data/lib/raml/exceptions.rb +1 -0
  7. data/lib/raml/mixin/bodies.rb +3 -3
  8. data/lib/raml/mixin/documentable.rb +3 -8
  9. data/lib/raml/mixin/global.rb +14 -10
  10. data/lib/raml/mixin/headers.rb +1 -1
  11. data/lib/raml/mixin/merge.rb +4 -4
  12. data/lib/raml/mixin/secured_by.rb +27 -0
  13. data/lib/raml/mixin/validation.rb +27 -27
  14. data/lib/raml/node.rb +22 -80
  15. data/lib/raml/node/abstract_method.rb +7 -7
  16. data/lib/raml/node/abstract_resource.rb +17 -7
  17. data/lib/raml/node/body.rb +12 -10
  18. data/lib/raml/node/documentation.rb +0 -8
  19. data/lib/raml/node/method.rb +5 -7
  20. data/lib/raml/node/parameter/abstract_parameter.rb +22 -24
  21. data/lib/raml/node/parametized_reference.rb +3 -3
  22. data/lib/raml/node/resource.rb +0 -2
  23. data/lib/raml/node/resource_type.rb +9 -9
  24. data/lib/raml/node/resource_type_reference.rb +2 -2
  25. data/lib/raml/node/response.rb +0 -2
  26. data/lib/raml/node/root.rb +66 -57
  27. data/lib/raml/node/schema.rb +3 -9
  28. data/lib/raml/node/schema_reference.rb +2 -2
  29. data/lib/raml/node/security_scheme.rb +47 -0
  30. data/lib/raml/node/security_scheme_reference.rb +5 -0
  31. data/lib/raml/node/trait.rb +8 -8
  32. data/lib/raml/node/trait_reference.rb +2 -2
  33. data/lib/raml/parser.rb +25 -16
  34. data/lib/raml/version.rb +1 -1
  35. data/raml_ruby.gemspec +3 -7
  36. data/test/apis/box-api.raml +1447 -1447
  37. data/test/apis/instagram-api.raml +48 -48
  38. data/test/apis/stripe-api.raml +4266 -4266
  39. data/test/apis/twilio-rest-api.raml +47 -47
  40. data/test/apis/twitter-rest-api.raml +1883 -1883
  41. data/test/raml/body_spec.rb +22 -39
  42. data/test/raml/documentation_spec.rb +2 -12
  43. data/test/raml/method_spec.rb +112 -93
  44. data/test/raml/parameter/abstract_parameter_spec.rb +9 -34
  45. data/test/raml/parameter/query_parameter_spec.rb +0 -15
  46. data/test/raml/parameter/uri_parameter_spec.rb +1 -16
  47. data/test/raml/resource_spec.rb +59 -41
  48. data/test/raml/resource_type_spec.rb +13 -13
  49. data/test/raml/response_spec.rb +23 -36
  50. data/test/raml/root_spec.rb +85 -18
  51. data/test/raml/security_scheme_spec.rb +71 -0
  52. data/test/raml/spec_helper.rb +2 -1
  53. data/test/raml/template_spec.rb +92 -92
  54. data/test/raml/trait_spec.rb +7 -7
  55. metadata +14 -74
  56. data/templates/abstract_parameter.slim +0 -68
  57. data/templates/body.slim +0 -15
  58. data/templates/collapse.slim +0 -10
  59. data/templates/documentation.slim +0 -2
  60. data/templates/method.slim +0 -38
  61. data/templates/resource.slim +0 -33
  62. data/templates/response.slim +0 -13
  63. data/templates/root.slim +0 -39
  64. data/templates/style.sass +0 -119
@@ -17,7 +17,7 @@ describe Raml::Body do
17
17
  "type": "object"
18
18
  }
19
19
  ))
20
- }
20
+ }
21
21
  let(:form_body_data) {
22
22
  YAML.load(%q(
23
23
  formParameters:
@@ -28,13 +28,19 @@ describe Raml::Body do
28
28
  let(:root) { Raml::Root.new 'title' => 'x', 'baseUri' => 'http://foo.com', 'schemas' => [{'Job' => 'xxx'}] }
29
29
 
30
30
  subject { Raml::Body.new media_type, body_data, root }
31
-
31
+
32
32
  describe '#initialize' do
33
33
  context 'when the media type is valid' do
34
34
  it "inits body with media_type" do
35
35
  expect( subject.media_type ).to eq media_type
36
36
  end
37
37
  end
38
+ context 'when the media type is "*/*"' do
39
+ let(:media_type) { '*/*' }
40
+ it 'inits the body with the media_type' do
41
+ expect( subject.media_type ).to eq media_type
42
+ end
43
+ end
38
44
  context 'when the media type is invalid' do
39
45
  let(:media_type) { 'foo' }
40
46
  it { expect { subject }.to raise_error Raml::InvalidMediaType }
@@ -91,7 +97,7 @@ describe Raml::Body do
91
97
  it { expect { subject }.to raise_error Raml::InvalidProperty, /formParameters/ }
92
98
  end
93
99
  end
94
-
100
+
95
101
  context 'when a schema property is not provided' do
96
102
  it { expect { subject }.to_not raise_error }
97
103
  end
@@ -118,10 +124,10 @@ describe Raml::Body do
118
124
  it { expect { subject }.to raise_error Raml::InvalidProperty, /schema/ }
119
125
  end
120
126
  end
121
- end
127
+ end
122
128
  end
123
129
  end
124
-
130
+
125
131
  describe '#form_parameters' do
126
132
  context 'when body is not a web form' do
127
133
  it 'returns no form parameters' do
@@ -136,7 +142,7 @@ describe Raml::Body do
136
142
  end
137
143
  end
138
144
  end
139
-
145
+
140
146
  describe '#web_form?' do
141
147
  context 'when body isnt a web form' do
142
148
  it { should_not be_web_form }
@@ -179,9 +185,9 @@ describe Raml::Body do
179
185
  end
180
186
  end
181
187
  context 'formParameters properties' do
182
- let(:mixin_data) { {
188
+ let(:mixin_data) { {
183
189
  'formParameters' => {
184
- 'param1' => {'description' => 'foo'},
190
+ 'param1' => {'description' => 'foo'},
185
191
  'param2' => {'description' => 'bar'}
186
192
  }
187
193
  } }
@@ -206,16 +212,16 @@ describe Raml::Body do
206
212
  end
207
213
  end
208
214
  context 'formParameters properties' do
209
- let(:body_data) { {
215
+ let(:body_data) { {
210
216
  'formParameters' => {
211
- 'param1' => {'description' => 'foo'},
217
+ 'param1' => {'description' => 'foo'},
212
218
  'param2' => {'description' => 'bar'}
213
219
  }
214
220
  } }
215
221
  context 'when the merged in body form parameters are different from the form parametes of the body merged into' do
216
- let(:mixin_data) { {
222
+ let(:mixin_data) { {
217
223
  'formParameters' => {
218
- 'param3' => {'description' => 'foo2'},
224
+ 'param3' => {'description' => 'foo2'},
219
225
  'param4' => {'description' => 'bar2'}
220
226
  }
221
227
  } }
@@ -224,10 +230,10 @@ describe Raml::Body do
224
230
  end
225
231
  end
226
232
  context 'when the merged in body form parameters overlap with the form parametes of the body merged into' do
227
- let(:mixin_data) { {
233
+ let(:mixin_data) { {
228
234
  'formParameters' => {
229
- 'param2' => {'description' => 'bar3', 'displayName' => 'Param 3'},
230
- 'param3' => {'description' => 'foo2'},
235
+ 'param2' => {'description' => 'bar3', 'displayName' => 'Param 3'},
236
+ 'param3' => {'description' => 'foo2'},
231
237
  'param4' => {'description' => 'bar2'}
232
238
  }
233
239
  } }
@@ -236,33 +242,10 @@ describe Raml::Body do
236
242
  body.form_parameters['param2'].display_name.should eq mixin.form_parameters['param2'].display_name
237
243
  body.form_parameters['param2'].description.should eq mixin.form_parameters['param2'].description
238
244
  end
239
- end
245
+ end
240
246
  end
241
247
  end
242
248
  end
243
249
  end
244
250
  end
245
-
246
- describe '#document' do
247
- context 'when the body is not a form body' do
248
- it 'returns a String' do
249
- subject.document.should be_a String
250
- end
251
- it 'should render the template' do
252
- mock(Slim::Template).new(/templates\/body.slim\z/, is_a(Hash)).mock!.render(is_a(Raml::Node)) { '' }
253
- subject.document
254
- end
255
- end
256
- context 'when the body is a form body' do
257
- let(:media_type) { 'application/x-www-form-urlencoded' }
258
- let(:body_data) { form_body_data }
259
- it 'returns a String' do
260
- subject.document.should be_a String
261
- end
262
- it 'should render the template' do
263
- mock(Slim::Template).new(/templates\/body.slim\z/, is_a(Hash)).mock!.render(is_a(Raml::Node)) { '' }
264
- subject.document
265
- end
266
- end
267
- end
268
251
  end
@@ -34,16 +34,6 @@ You can retrieve a representation of a resource by GETting its url. The easiest
34
34
  * 500 SERVER ERROR: We couldn't return the representation due to an internal server error.
35
35
  * 503 SERVICE UNAVAILABLE: We are temporarily unable to return the representation. Please wait for a bit and try again.
36
36
  EOS
37
- }
37
+ }
38
38
  subject { Raml::Documentation.new(title, {'content' => content }, root) }
39
-
40
- describe '#document' do
41
- it 'returns a String' do
42
- subject.document.should be_a String
43
- end
44
- it 'should render the template' do
45
- mock(Slim::Template).new(/templates\/documentation.slim\z/, is_a(Hash)).mock!.render(is_a(Raml::Node)) { '' }
46
- subject.document
47
- end
48
- end
49
- end
39
+ end
@@ -34,7 +34,7 @@ describe Raml::Method do
34
34
  it "should instanciate Method" do
35
35
  subject
36
36
  end
37
-
37
+
38
38
  context 'when the method is a method defined in RFC2616 or RFC5789' do
39
39
  %w(options get head post put delete trace connect patch).each do |method|
40
40
  context "when the method is #{method}" do
@@ -51,7 +51,7 @@ describe Raml::Method do
51
51
  end
52
52
  end
53
53
  end
54
-
54
+
55
55
  context 'when description property is not given' do
56
56
  let(:data) { {} }
57
57
  it { expect { subject }.to_not raise_error }
@@ -67,12 +67,9 @@ describe Raml::Method do
67
67
  it 'should store the value' do
68
68
  subject.description.should eq data['description']
69
69
  end
70
- it 'uses the description in the documentation' do
71
- subject.document.should include data['description']
72
- end
73
70
  end
74
71
  end
75
-
72
+
76
73
  context 'when the headers parameter is given' do
77
74
  context 'when the headers property is well formed' do
78
75
  let (:data) {
@@ -103,7 +100,7 @@ describe Raml::Method do
103
100
  it { expect { subject }.to raise_error Raml::InvalidProperty, /headers/ }
104
101
  end
105
102
  end
106
-
103
+
107
104
  context 'when the protocols property is missing' do
108
105
  let(:data) { { } }
109
106
  it { expect{ subject }.to_not raise_error }
@@ -141,7 +138,7 @@ describe Raml::Method do
141
138
  end
142
139
  end
143
140
  end
144
-
141
+
145
142
  context 'when a queryParameters property is given' do
146
143
  context 'when the queryParameters property is well formed' do
147
144
  let(:data) {
@@ -164,7 +161,7 @@ describe Raml::Method do
164
161
  )
165
162
  )
166
163
  }
167
-
164
+
168
165
  it { expect { subject }.to_not raise_error }
169
166
  it 'stores all as Raml::Parameter::UriParameter instances' do
170
167
  expect( subject.query_parameters.values ).to all( be_a Raml::Parameter::QueryParameter )
@@ -199,7 +196,7 @@ describe Raml::Method do
199
196
  )
200
197
  )
201
198
  }
202
-
199
+
203
200
  it { expect { subject }.to_not raise_error }
204
201
  it 'stores all as Raml::Body instances' do
205
202
  expect( subject.bodies.values ).to all( be_a Raml::Body )
@@ -219,7 +216,7 @@ describe Raml::Method do
219
216
  it { expect { subject }.to raise_error Raml::InvalidProperty, /body/ }
220
217
  end
221
218
  end
222
-
219
+
223
220
  context 'when a responses property is given' do
224
221
  context 'when the responses property is well formed' do
225
222
  let(:data) {
@@ -235,7 +232,7 @@ describe Raml::Method do
235
232
  )
236
233
  )
237
234
  }
238
-
235
+
239
236
  it { expect { subject }.to_not raise_error }
240
237
  it 'stores all as Raml::Response instances' do
241
238
  expect( subject.responses.values ).to all( be_a Raml::Response )
@@ -257,7 +254,7 @@ describe Raml::Method do
257
254
  end
258
255
 
259
256
  context 'when an is property is given' do
260
- let(:root) {
257
+ let(:root) {
261
258
  Raml::Root.new 'title' => 'x', 'baseUri' => 'http://foo.com', 'traits' => [
262
259
  { 'secured' => {} },
263
260
  { 'paged' => {} },
@@ -274,11 +271,11 @@ describe Raml::Method do
274
271
  end
275
272
  end
276
273
  context 'when the property is an array of trait references with parameters' do
277
- let(:data) { {
278
- 'is' => [
279
- {'secured' => {'tokenName' => 'access_token'}},
280
- {'paged' => {'maxPages' => 10 }}
281
- ]
274
+ let(:data) { {
275
+ 'is' => [
276
+ {'secured' => {'tokenName' => 'access_token'}},
277
+ {'paged' => {'maxPages' => 10 }}
278
+ ]
282
279
  } }
283
280
  it { expect { subject }.to_not raise_error }
284
281
  it 'should store the trait references' do
@@ -287,11 +284,11 @@ describe Raml::Method do
287
284
  end
288
285
  end
289
286
  context 'when the property is an array of trait definitions' do
290
- let(:data) { {
291
- 'is' => [
292
- {'queryParameters' => {'tokenName' => {'description'=>'foo'}}},
287
+ let(:data) { {
288
+ 'is' => [
289
+ {'queryParameters' => {'tokenName' => {'description'=>'foo'}}},
293
290
  {'queryParameters' => {'numPages' => {'description'=>'bar'}}}
294
- ]
291
+ ]
295
292
  } }
296
293
  it { expect { subject }.to_not raise_error }
297
294
  it 'should store the traits' do
@@ -301,12 +298,12 @@ describe Raml::Method do
301
298
  end
302
299
  end
303
300
  context 'when the property is an array of mixed trait refrences, trait refrences with parameters, and trait definitions' do
304
- let(:data) { {
305
- 'is' => [
306
- {'secured' => {'tokenName' => 'access_token'}},
301
+ let(:data) { {
302
+ 'is' => [
303
+ {'secured' => {'tokenName' => 'access_token'}},
307
304
  {'queryParameters' => {'numPages' => {'description'=>'bar'}}},
308
305
  'rateLimited'
309
- ]
306
+ ]
310
307
  } }
311
308
  it { expect { subject }.to_not raise_error }
312
309
  it 'should store the traits' do
@@ -350,6 +347,38 @@ describe Raml::Method do
350
347
  }
351
348
  it { expect {subject }.to raise_error Raml::InvalidProperty, /Optional properties/ }
352
349
  end
350
+
351
+ context 'when null is given as a property' do
352
+ let(:data) {YAML.load('!!null')}
353
+ it { expect{ subject }.to_not raise_error }
354
+ end
355
+
356
+ context 'when the securedBy property is defined' do
357
+ let (:root_data) { {'title' => 'x', 'baseUri' => 'http://foo.com', 'securitySchemes' => ['oauth_2_0' => {'type' => 'OAuth 2.0'}, 'oauth_1_0' => {'type' => 'OAuth 1.0'}] } }
358
+ context 'when the securedBy property is an array of strings' do
359
+ let(:data) { { 'securedBy' => ['oauth_2_0', 'oauth_1_0'] } }
360
+ it { expect{ subject }.to_not raise_error }
361
+ end
362
+ context 'when the securedBy property is an array of strings and "null"' do
363
+ let(:data) { { 'securedBy' => ['oauth_2_0', 'null'] } }
364
+ it { expect{ subject }.to_not raise_error }
365
+ end
366
+ context 'when the securedBy property is an array of hash with single key' do
367
+ let(:data) { { 'securedBy' => ['oauth_2_0' => {'scopes' => 'ADMINISTRATOR'}] } }
368
+ it { expect{ subject }.to_not raise_error }
369
+ end
370
+ context 'when the securedBy property references a missing security scheme' do
371
+ let(:data) { { 'securedBy' => ['bar'] } }
372
+ it { expect{ subject }.to raise_error Raml::UnknownSecuritySchemeReference, /bar/}
373
+ end
374
+ context 'when the securedBy property is included it is accessible and' do
375
+ let(:data) { { 'securedBy' => ['oauth_2_0', 'oauth_1_0'] } }
376
+ it 'exposes the schema references' do
377
+ expect( subject.secured_by.values ).to all( be_a Raml::SecuritySchemeReference )
378
+ subject.secured_by.keys.should contain_exactly('oauth_2_0', 'oauth_1_0')
379
+ end
380
+ end
381
+ end
353
382
  end
354
383
 
355
384
  describe '#merge' do
@@ -371,9 +400,9 @@ describe Raml::Method do
371
400
  end
372
401
  end
373
402
  context 'headers properties' do
374
- let(:trait_data) { {
403
+ let(:trait_data) { {
375
404
  'headers' => {
376
- 'header1' => {'description' => 'foo'},
405
+ 'header1' => {'description' => 'foo'},
377
406
  'header2' => {'description' => 'bar'}
378
407
  }
379
408
  } }
@@ -382,9 +411,9 @@ describe Raml::Method do
382
411
  end
383
412
  end
384
413
  context 'queryParameters properties' do
385
- let(:trait_data) { {
414
+ let(:trait_data) { {
386
415
  'queryParameters' => {
387
- 'param1' => {'description' => 'foo'},
416
+ 'param1' => {'description' => 'foo'},
388
417
  'param2' => {'description' => 'bar'}
389
418
  }
390
419
  } }
@@ -393,9 +422,9 @@ describe Raml::Method do
393
422
  end
394
423
  end
395
424
  context 'body property' do
396
- let(:trait_data) { {
425
+ let(:trait_data) { {
397
426
  'body' => {
398
- 'text/mime1' => {'schema' => 'foo'},
427
+ 'text/mime1' => {'schema' => 'foo'},
399
428
  'text/mime2' => {'schema' => 'bar'}
400
429
  }
401
430
  } }
@@ -404,9 +433,9 @@ describe Raml::Method do
404
433
  end
405
434
  end
406
435
  context 'responses property' do
407
- let(:trait_data) { {
436
+ let(:trait_data) { {
408
437
  'responses' => {
409
- 200 => {'description' => 'foo'},
438
+ 200 => {'description' => 'foo'},
410
439
  404 => {'description' => 'bar'}
411
440
  }
412
441
  } }
@@ -438,16 +467,16 @@ describe Raml::Method do
438
467
  end
439
468
  end
440
469
  context 'headers properties' do
441
- let(:method_data) { {
470
+ let(:method_data) { {
442
471
  'headers' => {
443
- 'header1' => {'description' => 'foo'},
472
+ 'header1' => {'description' => 'foo'},
444
473
  'header2' => {'description' => 'bar'}
445
474
  }
446
475
  } }
447
476
  context 'when the trait headers are different from the method headers' do
448
- let(:trait_data) { {
477
+ let(:trait_data) { {
449
478
  'headers' => {
450
- 'header3' => {'description' => 'foo2'},
479
+ 'header3' => {'description' => 'foo2'},
451
480
  'header4' => {'description' => 'bar2'}
452
481
  }
453
482
  } }
@@ -456,10 +485,10 @@ describe Raml::Method do
456
485
  end
457
486
  end
458
487
  context 'when the trait headers overlap the the method headers' do
459
- let(:trait_data) { {
488
+ let(:trait_data) { {
460
489
  'headers' => {
461
- 'header2' => {'displayName' => 'Header 3'},
462
- 'header3' => {'description' => 'foo2'},
490
+ 'header2' => {'displayName' => 'Header 3'},
491
+ 'header3' => {'description' => 'foo2'},
463
492
  'header4' => {'description' => 'bar2'}
464
493
  }
465
494
  } }
@@ -467,19 +496,19 @@ describe Raml::Method do
467
496
  method.merge(trait).headers.keys.should contain_exactly('header1', 'header2', 'header3', 'header4')
468
497
  method.headers['header2'].display_name.should eq trait.headers['header2'].display_name
469
498
  end
470
- end
499
+ end
471
500
  end
472
501
  context 'queryParameters properties' do
473
- let(:method_data) { {
502
+ let(:method_data) { {
474
503
  'queryParameters' => {
475
- 'param1' => {'description' => 'foo'},
504
+ 'param1' => {'description' => 'foo'},
476
505
  'param2' => {'description' => 'bar'}
477
506
  }
478
507
  } }
479
508
  context 'when the trait query parameters are different from the method headers' do
480
- let(:trait_data) { {
509
+ let(:trait_data) { {
481
510
  'queryParameters' => {
482
- 'param3' => {'description' => 'foo2'},
511
+ 'param3' => {'description' => 'foo2'},
483
512
  'param4' => {'description' => 'bar2'}
484
513
  }
485
514
  } }
@@ -488,10 +517,10 @@ describe Raml::Method do
488
517
  end
489
518
  end
490
519
  context 'when the trait query parameters overlap the the method query parameters' do
491
- let(:trait_data) { {
520
+ let(:trait_data) { {
492
521
  'queryParameters' => {
493
- 'param2' => {'displayName' => 'Param 3'},
494
- 'param3' => {'description' => 'foo2'},
522
+ 'param2' => {'displayName' => 'Param 3'},
523
+ 'param3' => {'description' => 'foo2'},
495
524
  'param4' => {'description' => 'bar2'}
496
525
  }
497
526
  } }
@@ -499,19 +528,19 @@ describe Raml::Method do
499
528
  method.merge(trait).query_parameters.keys.should contain_exactly('param1', 'param2', 'param3', 'param4')
500
529
  method.query_parameters['param2'].display_name.should eq trait.query_parameters['param2'].display_name
501
530
  end
502
- end
531
+ end
503
532
  end
504
533
  context 'body property' do
505
- let(:method_data) { {
534
+ let(:method_data) { {
506
535
  'body' => {
507
- 'text/mime1' => {'schema' => 'foo'},
536
+ 'text/mime1' => {'schema' => 'foo'},
508
537
  'text/mime2' => {'schema' => 'bar'}
509
538
  }
510
539
  } }
511
540
  context 'when the trait query parameters are different from the method headers' do
512
- let(:trait_data) { {
541
+ let(:trait_data) { {
513
542
  'body' => {
514
- 'text/mime3' => {'schema' => 'foo2'},
543
+ 'text/mime3' => {'schema' => 'foo2'},
515
544
  'text/mime4' => {'schema' => 'bar2'}
516
545
  }
517
546
  } }
@@ -520,10 +549,10 @@ describe Raml::Method do
520
549
  end
521
550
  end
522
551
  context 'when the trait query parameters overlap the the method query parameters' do
523
- let(:trait_data) { {
552
+ let(:trait_data) { {
524
553
  'body' => {
525
- 'text/mime2' => {'example' => 'Example 2'},
526
- 'text/mime3' => {'schema' => 'foo2'},
554
+ 'text/mime2' => {'example' => 'Example 2'},
555
+ 'text/mime3' => {'schema' => 'foo2'},
527
556
  'text/mime4' => {'schema' => 'bar2'}
528
557
  }
529
558
  } }
@@ -531,19 +560,19 @@ describe Raml::Method do
531
560
  method.merge(trait).bodies.keys.should contain_exactly('text/mime1', 'text/mime2', 'text/mime3', 'text/mime4')
532
561
  method.bodies['text/mime2'].example.should eq trait.bodies['text/mime2'].example
533
562
  end
534
- end
563
+ end
535
564
  end
536
565
  context 'responses property' do
537
- let(:method_data) { {
566
+ let(:method_data) { {
538
567
  'responses' => {
539
- 200 => {'description' => 'foo', 'body' => { 'text/mime1' => {'schema' => 'schema1'} } },
568
+ 200 => {'description' => 'foo', 'body' => { 'text/mime1' => {'schema' => 'schema1'} } },
540
569
  404 => {'description' => 'bar'}
541
570
  }
542
571
  } }
543
572
  context 'when the trait response status codes are different from the method responses status codes' do
544
- let(:trait_data) { {
573
+ let(:trait_data) { {
545
574
  'responses' => {
546
- 201 => {'description' => 'foo2'},
575
+ 201 => {'description' => 'foo2'},
547
576
  403 => {'description' => 'bar2'}
548
577
  }
549
578
  } }
@@ -552,10 +581,10 @@ describe Raml::Method do
552
581
  end
553
582
  end
554
583
  context 'when the trait query parameters overlap the the method query parameters' do
555
- let(:trait_data) { {
584
+ let(:trait_data) { {
556
585
  'responses' => {
557
- 200 => {'description' => 'foo', 'body' => { 'text/mime2' => {'schema' => 'schema2'} } },
558
- 201 => {'description' => 'foo2'},
586
+ 200 => {'description' => 'foo', 'body' => { 'text/mime2' => {'schema' => 'schema2'} } },
587
+ 201 => {'description' => 'foo2'},
559
588
  403 => {'description' => 'bar2'}
560
589
  }
561
590
  } }
@@ -563,7 +592,7 @@ describe Raml::Method do
563
592
  method.merge(trait).responses.keys.should contain_exactly(200, 404, 201, 403)
564
593
  method.responses[200].bodies.keys.should contain_exactly('text/mime1', 'text/mime2')
565
594
  end
566
- end
595
+ end
567
596
  end
568
597
  end
569
598
  end
@@ -571,7 +600,7 @@ describe Raml::Method do
571
600
 
572
601
  describe '#apply_traits' do
573
602
  let(:root_data) { {
574
- 'title' => 'x',
603
+ 'title' => 'x',
575
604
  'baseUri' => 'http://foo.com',
576
605
  '/users' => {
577
606
  '/comments' => {
@@ -592,16 +621,16 @@ describe Raml::Method do
592
621
  end
593
622
  end
594
623
  context 'when the method has multiple traits' do
595
- let(:method_data) { {
596
- 'is' => [
597
- {
624
+ let(:method_data) { {
625
+ 'is' => [
626
+ {
598
627
  'description' => 'trait description',
599
628
  'headers' => { 'header1' => { 'description' => 'header1' } }
600
629
  },
601
630
  {
602
631
  'description' => 'trait description 2',
603
632
  'headers' => { 'header2' => { 'description' => 'header2' } }
604
- }
633
+ }
605
634
  ]
606
635
  } }
607
636
  it 'applies them in order of precedence, right to left' do
@@ -620,39 +649,39 @@ describe Raml::Method do
620
649
  end
621
650
  context 'when the method has traits' do
622
651
  let(:resource_trait_data) {
623
- [
624
- {
652
+ [
653
+ {
625
654
  'description' => 'trait4 description',
626
- 'headers' => {
655
+ 'headers' => {
627
656
  'header3' => { 'description' => 'trait4' },
628
- 'header4' => { 'description' => 'trait4' }
657
+ 'header4' => { 'description' => 'trait4' }
629
658
  }
630
659
  },
631
660
  {
632
661
  'description' => 'trait3 description',
633
- 'headers' => {
662
+ 'headers' => {
634
663
  'header2' => { 'description' => 'trait3' },
635
664
  'header3' => { 'description' => 'trait3' }
636
665
  }
637
- }
666
+ }
638
667
  ]
639
668
  }
640
- let(:method_data) { {
669
+ let(:method_data) { {
641
670
  'description' => 'method description',
642
- 'is' => [
643
- {
671
+ 'is' => [
672
+ {
644
673
  'description' => 'trait2 description',
645
- 'headers' => {
674
+ 'headers' => {
646
675
  'header1' => { 'description' => 'trait2' },
647
676
  'header2' => { 'description' => 'trait2' }
648
677
  }
649
678
  },
650
679
  {
651
680
  'description' => 'trait1 description',
652
- 'headers' => {
681
+ 'headers' => {
653
682
  'header1' => { 'description' => 'trait1' }
654
683
  }
655
- }
684
+ }
656
685
  ]
657
686
  } }
658
687
  it 'applies method traits first in reverse order, then resource traits in reverse order' do
@@ -688,14 +717,4 @@ describe Raml::Method do
688
717
  end
689
718
  end
690
719
  end
691
-
692
- describe '#document' do
693
- it 'returns a String' do
694
- subject.document.should be_a String
695
- end
696
- it 'should render the template' do
697
- mock(Slim::Template).new(/templates\/method.slim\z/, is_a(Hash)).mock!.render(is_a(Raml::Node)) { '' }
698
- subject.document
699
- end
700
- end
701
720
  end