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
@@ -16,7 +16,7 @@ describe Raml::Root do
16
16
  }
17
17
 
18
18
  subject { Raml::Root.new data }
19
-
19
+
20
20
  describe '#new' do
21
21
  it "should init root" do
22
22
  expect { subject }.to_not raise_error
@@ -30,7 +30,7 @@ describe Raml::Root do
30
30
  let(:data) { { 'title' => 1, 'baseUri' => 'x' } }
31
31
  it { expect{ subject }.to raise_error Raml::InvalidProperty, /title/ }
32
32
  end
33
-
33
+
34
34
  context 'when the baseUri property is missing' do
35
35
  let(:data) { { 'title' => 'x' } }
36
36
  it { expect{ subject }.to raise_error Raml::RequiredPropertyMissing, /baseUri/ }
@@ -72,7 +72,7 @@ describe Raml::Root do
72
72
  let(:data) { { 'title' => 'x', 'baseUri' => 'https://api.stormpath.com/}version}' } }
73
73
  it { expect{ subject }.to raise_error Raml::InvalidProperty, /baseUri/ }
74
74
  end
75
-
75
+
76
76
  context 'when the protocols property is missing' do
77
77
  let(:data) { { 'title' => 'x', 'baseUri' => 'http://foo.com' } }
78
78
  it { expect{ subject }.to_not raise_error }
@@ -108,7 +108,7 @@ describe Raml::Root do
108
108
  subject.protocols.should eq [ 'HTTP', 'HTTPS' ]
109
109
  end
110
110
  end
111
-
111
+
112
112
  [
113
113
  'application/json',
114
114
  'application/x-yaml',
@@ -128,7 +128,7 @@ describe Raml::Root do
128
128
  let(:data) { { 'title' => 'x', 'baseUri' => 'http://foo.com', 'media_type' => 'foo' } }
129
129
  it { expect{ subject }.to raise_error Raml::InvalidProperty, /mediaType/ }
130
130
  end
131
-
131
+
132
132
  context 'when the schemas property is an array of maps with string keys and values' do
133
133
  let(:data) { { 'title' => 'x', 'baseUri' => 'http://foo.com', 'schemas' => [{'foo'=>'bar'}] } }
134
134
  it { expect{ subject }.to_not raise_error }
@@ -175,7 +175,7 @@ describe Raml::Root do
175
175
  let(:data) { { 'title' => 'x', 'baseUri' => 'http://foo.com', 'schemas' => [{'foo'=>'bar'},{'foo'=>'boo'}] } }
176
176
  it { expect{ subject }.to raise_error Raml::InvalidProperty, /schemas/ }
177
177
  end
178
-
178
+
179
179
  context 'when the baseUriParameter property is well formed' do
180
180
  let(:data) {
181
181
  YAML.load(
@@ -231,7 +231,7 @@ describe Raml::Root do
231
231
  let(:data) { { 'title' => 'x', 'baseUri' => 'http://foo.com', 'baseUriParameters' => { 'version' => {}} } }
232
232
  it { expect { subject }.to raise_error Raml::InvalidProperty, /baseUriParameters/ }
233
233
  end
234
-
234
+
235
235
  context 'when the documentation parameter is given and valid' do
236
236
  let(:data) {
237
237
  YAML.load(
@@ -275,7 +275,7 @@ describe Raml::Root do
275
275
  let(:data) { { 'title' => 'x', 'baseUri' => 'http://foo.com', 'documentation' => [{'title' => 'x', 'content' => ''}] } }
276
276
  it { expect { subject }.to raise_error Raml::InvalidProperty, /document/ }
277
277
  end
278
-
278
+
279
279
  context 'when top-level resources are defined' do
280
280
  let(:data) {
281
281
  YAML.load(
@@ -413,6 +413,83 @@ describe Raml::Root do
413
413
  it { expect{ subject }.to raise_error Raml::InvalidProperty, /traits/ }
414
414
  end
415
415
  end
416
+
417
+ context 'when the securedBy property is defined' do
418
+ context 'when the securitySchemes property is an array of strings' do
419
+ let(:data) { { 'title' => 'x', 'baseUri' => 'http://foo.com', 'securedBy' => ['oauth_2_0', 'oauth_1_0'], 'securitySchemes' => ['oauth_2_0' => {'type' => 'OAuth 2.0'}, 'oauth_1_0' => {'type' => 'OAuth 1.0'}] } }
420
+ it { expect{ subject }.to_not raise_error }
421
+ end
422
+ context 'when the securitySchemes property is an array of strings and "null"' do
423
+ let(:data) { { 'title' => 'x', 'baseUri' => 'http://foo.com', 'securedBy' => ['oauth_2_0', 'null'], 'securitySchemes' => ['oauth_2_0' => {'type' => 'OAuth 2.0'}] } }
424
+ it { expect{ subject }.to_not raise_error }
425
+ end
426
+ context 'when the securitySchemes property is an array of hash with single key' do
427
+ let(:data) { { 'title' => 'x', 'baseUri' => 'http://foo.com', 'securedBy' => ['oauth_2_0' => {'scopes' => 'ADMINISTRATOR'}], 'securitySchemes' => ['oauth_2_0' => {'type' => 'OAuth 2.0'}] } }
428
+ it { expect{ subject }.to_not raise_error }
429
+ end
430
+ context 'when the securitySchemes property references a missing security scheme' do
431
+ let(:data) { { 'title' => 'x', 'baseUri' => 'http://foo.com', 'securedBy' => ['bar'], 'securitySchemes' => ['oauth_2_0' => {'type' => 'OAuth 2.0'}] } }
432
+ it { expect{ subject }.to raise_error Raml::UnknownSecuritySchemeReference, /bar/}
433
+ end
434
+ end
435
+
436
+ context 'when the securitySchemes property is defined' do
437
+ context 'when the securitySchemes property is an array of maps with string keys and and map values' do
438
+ let(:data) { { 'title' => 'x', 'baseUri' => 'http://foo.com', 'securitySchemes' => [{'foo'=>{},'boo'=>{}}] } }
439
+ it { expect{ subject }.to_not raise_error }
440
+ end
441
+ context 'when the securitySchemes property is an array with a single map' do
442
+ let(:data) { { 'title' => 'x', 'baseUri' => 'http://foo.com', 'securitySchemes' => [{'foo'=>{}}] } }
443
+ it 'returns the SecurityScheme in the #security_schemes method' do
444
+ subject.security_schemes.should be_a Hash
445
+ subject.security_schemes.keys.should contain_exactly('foo')
446
+ subject.security_schemes['foo'].should be_a Raml::SecurityScheme
447
+ subject.security_schemes['foo'].name.should == 'foo'
448
+ end
449
+ context 'when the securitySchemes property is an array with a single map with multiple types' do
450
+ let(:data) { { 'title' => 'x', 'baseUri' => 'http://foo.com', 'securitySchemes' => [{'foo'=>{},'boo'=>{}}] } }
451
+ it 'returns the SecuritySchemes in the #security_schemes method' do
452
+ subject.security_schemes.should be_a Hash
453
+ subject.security_schemes.keys.should contain_exactly('foo', 'boo')
454
+ subject.security_schemes.values.should all(be_a Raml::SecurityScheme)
455
+ subject.security_schemes.values.map(&:name).should contain_exactly('foo', 'boo')
456
+ end
457
+ end
458
+ end
459
+ context 'when the securitySchemes property is an array with multiple maps' do
460
+ let(:data) { { 'title' => 'x', 'baseUri' => 'http://foo.com', 'securitySchemes' => [{'foo'=>{}},{'boo'=>{}}] } }
461
+ it 'returns the merged maps in the #security_schemes method' do
462
+ subject.security_schemes.should be_a Hash
463
+ subject.security_schemes.keys.should contain_exactly('foo', 'boo')
464
+ subject.security_schemes.values.should all(be_a Raml::SecurityScheme)
465
+ subject.security_schemes.values.map(&:name).should contain_exactly('foo', 'boo')
466
+ end
467
+ end
468
+ context 'when the securitySchemes property is not an array' do
469
+ let(:data) { { 'title' => 'x', 'baseUri' => 'http://foo.com', 'securitySchemes' => 'x' } }
470
+ it { expect{ subject }.to raise_error Raml::InvalidProperty, /securitySchemes/ }
471
+ end
472
+ context 'when the securitySchemes property is an empty array' do
473
+ let(:data) { { 'title' => 'x', 'baseUri' => 'http://foo.com', 'securitySchemes' => [] } }
474
+ it { expect{ subject }.to_not raise_error }
475
+ end
476
+ context 'when the securitySchemes property is an array with some non-map elements' do
477
+ let(:data) { { 'title' => 'x', 'baseUri' => 'http://foo.com', 'securitySchemes' => [{'foo'=>{}}, 1] } }
478
+ it { expect{ subject }.to raise_error Raml::InvalidProperty, /securitySchemes/ }
479
+ end
480
+ context 'when the securitySchemes property is an array of maps with non-string keys' do
481
+ let(:data) { { 'title' => 'x', 'baseUri' => 'http://foo.com', 'securitySchemes' => [{1=>{}}] } }
482
+ it { expect{ subject }.to raise_error Raml::InvalidProperty, /securitySchemes/ }
483
+ end
484
+ context 'when the securitySchemes property is an array of maps with non-map values' do
485
+ let(:data) { { 'title' => 'x', 'baseUri' => 'http://foo.com', 'securitySchemes' => [{'foo'=>1}] } }
486
+ it { expect{ subject }.to raise_error Raml::InvalidProperty, /securitySchemes/ }
487
+ end
488
+ context 'when the securitySchemes property has duplicate type names' do
489
+ let(:data) { { 'title' => 'x', 'baseUri' => 'http://foo.com', 'securitySchemes' => [{'foo'=>{}},{'foo'=>{}}] } }
490
+ it { expect{ subject }.to raise_error Raml::InvalidProperty, /securitySchemes/ }
491
+ end
492
+ end
416
493
  end
417
494
 
418
495
  describe '#expand' do
@@ -642,14 +719,4 @@ describe Raml::Root do
642
719
  end
643
720
  end
644
721
  end
645
-
646
- describe '#document' do
647
- it 'returns a String' do
648
- subject.document.should be_a String
649
- end
650
- it 'should render the template' do
651
- mock(Slim::Template).new(/templates\/root.slim\z/, is_a(Hash)).mock!.render(is_a(Raml::Node)) { '' }
652
- subject.document
653
- end
654
- end
655
722
  end
@@ -0,0 +1,71 @@
1
+ # encoding: UTF-8
2
+ require_relative 'spec_helper'
3
+
4
+ describe Raml::SecurityScheme do
5
+ let(:name) { 'oauth_2_0' }
6
+ let(:data) {
7
+ YAML.load(%q(
8
+ description: |
9
+ Dropbox supports OAuth 2.0 for authenticating all API requests.
10
+ type: OAuth 2.0
11
+ describedBy:
12
+ headers:
13
+ Authorization:
14
+ description: |
15
+ Used to send a valid OAuth 2 access token. Do not use
16
+ with the "access_token" query string parameter.
17
+ type: string
18
+ queryParameters:
19
+ access_token:
20
+ description: |
21
+ Used to send a valid OAuth 2 access token. Do not use together with
22
+ the "Authorization" header
23
+ type: string
24
+ responses:
25
+ 401:
26
+ description: |
27
+ Bad or expired token. This can happen if the user or Dropbox
28
+ revoked or expired an access token. To fix, you should re-
29
+ authenticate the user.
30
+ 403:
31
+ description: |
32
+ Bad OAuth request (wrong consumer key, bad nonce, expired
33
+ timestamp...). Unfortunately, re-authenticating the user won't help here.
34
+ settings:
35
+ authorizationUri: https://www.dropbox.com/1/oauth2/authorize
36
+ accessTokenUri: https://api.dropbox.com/1/oauth2/token
37
+ authorizationGrants: [ code, token ]
38
+ ))
39
+ }
40
+ let(:root) { Raml::Root.new 'title' => 'x', 'baseUri' => 'http://foo.com' }
41
+
42
+ subject { Raml::SecurityScheme.new(name, data, root) }
43
+
44
+ describe '#new' do
45
+ context 'with valid arguments' do
46
+ it { expect { subject }.to_not raise_error }
47
+ it { should be_a Raml::SecurityScheme }
48
+ end
49
+ end
50
+
51
+ describe '#instantiate' do
52
+ context 'when the description property is given' do
53
+ before { data['description'] = 'Some text' }
54
+ it 'stores the description property' do
55
+ subject.instantiate({}).description.should eq data['description']
56
+ end
57
+ end
58
+ context 'when the type property is given' do
59
+ before { data['type'] = 'Some text' }
60
+ it 'stores the type property' do
61
+ subject.instantiate({}).type.should eq data['type']
62
+ end
63
+ end
64
+ context 'with invalid arguments' do
65
+ context 'when the securityScheme has nested resources' do
66
+ before { data['/foo'] = {} }
67
+ it { expect { subject.instantiate({}) }.to raise_error Raml::UnknownProperty, /\/foo/ }
68
+ end
69
+ end
70
+ end
71
+ end
@@ -1,9 +1,10 @@
1
1
  require_relative '../../lib/raml'
2
2
  require 'pry'
3
3
  require 'yaml'
4
+ require 'json'
4
5
 
5
6
  RSpec.configure do |config|
6
- config.expect_with :rspec do |c|
7
+ config.expect_with :rspec do |c|
7
8
  c.syntax = [:should, :expect]
8
9
  end
9
10
  config.mock_framework = :rr
@@ -3,96 +3,96 @@ require_relative 'spec_helper'
3
3
  describe Raml::Template do
4
4
  let(:root) { Raml::Root.new 'title' => 'x', 'baseUri' => 'http://foo.com' }
5
5
 
6
- describe '#new' do
7
- end
6
+ describe '#new' do
7
+ end
8
8
 
9
- describe '#interpolate' do
10
- subject { Raml::Template.new('foo', data, root).interpolate params }
11
- context 'when the data requires no parameters' do
12
- let(:params) { {} }
13
- context 'when its a shallow object' do
14
- let(:data ) { {'aaa' => 'bbb', 'ccc' => 'ddd', 'eee' => 'fff' } }
15
- it 'returns the same data that was inputted' do
16
- subject[1].should eq data
17
- end
18
- end
19
- context 'when its a nested object' do
20
- let(:data ) { {'aaa' => 'bbb', 'ccc' => [ 'ddd', 'eee' ], 'fff' => { 'ggg' => 'hhh', 'iii' => ['jjj'] } } }
21
- it 'returns the same data that was inputted' do
22
- subject[1].should eq data
23
- end
24
- end
25
- end
26
- context 'when the data requires parameters' do
27
- context 'when its a shallow object' do
28
- let(:data ) { {'aaa <<foo>>' => 'bbb', 'ccc' => '<<bar>> ddd', 'eee' => 'fff' } }
29
- context 'when a required parameter is missing' do
30
- let(:params) { { 'foo' => 'bar' } }
31
- it do
32
- expect { subject }.to raise_exception Raml::UnknownTypeOrTraitParameter
33
- end
34
- end
35
- context 'when all parameters are given' do
36
- let(:params) { { 'foo' => 'bar', 'bar' => 'baz' } }
37
- it 'returns the name with the parameter interpolated' do
38
- subject[1].should eq ({'aaa bar' => 'bbb', 'ccc' => 'baz ddd', 'eee' => 'fff' })
39
- end
40
- end
41
- end
42
- context 'when its a nested object' do
43
- let(:data ) { {'aaa <<foo>>' => 'bbb', 'ccc' => [ '<<bar>> ddd', 'eee' ], 'fff' => { 'ggg' => 'hhh', '<<baz>> iii' => ['<<jaz>> jjj'] } } }
44
- context 'when a required parameter is missing' do
45
- let(:params) { { 'foo' => 'bar' } }
46
- it do
47
- expect { subject }.to raise_exception Raml::UnknownTypeOrTraitParameter
48
- end
49
- end
50
- context 'when all parameters are given' do
51
- let(:params) { { 'foo' => 'bar', 'bar' => 'baz', 'baz' => 'jaz', 'jaz' => 'max' } }
52
- it 'returns the name with the parameter interpolated' do
53
- subject[1].should eq ({'aaa bar' => 'bbb', 'ccc' => [ 'baz ddd', 'eee' ], 'fff' => { 'ggg' => 'hhh', 'jaz iii' => ['max jjj'] } })
54
- end
55
- end
56
- end
57
- end
58
- context 'when function parameters are used' do
59
- context 'when the function is not known' do
60
- let(:params) { {'some_param' => 'test'} }
61
- let(:data ) { {'bar' => '<<some_param | !unknown>>'} }
62
- it do
63
- expect { subject }.to raise_exception Raml::UnknownTypeOrTraitParamFunction
64
- end
65
- end
66
- context 'when the function is singularize' do
67
- let(:data) { {'bar' => 'some <<some_param | !singularize>>'} }
68
- context 'when the parameter is plural' do
69
- let(:params) { {'some_param' => 'tests'} }
70
- it 'signularizes it' do
71
- subject[1]['bar'].should eq 'some test'
72
- end
73
- end
74
- context 'when the parameter is singular' do
75
- let(:params) { {'some_param' => 'test'} }
76
- it 'keeps it singular' do
77
- subject[1]['bar'].should eq 'some test'
78
- end
79
- end
80
- end
81
- context 'when the function is pluralize' do
82
- let(:data) { {'bar' => 'some <<some_param | !pluralize>>'} }
83
- context 'when the parameter is singular' do
84
- let(:params) { {'some_param' => 'test'} }
85
- it 'pluralizes it' do
86
- subject[1]['bar'].should eq 'some tests'
87
- end
88
- end
89
- context 'when the parameter is plural' do
90
- let(:params) { {'some_param' => 'tests'} }
91
- it 'keeps it plural' do
92
- subject[1]['bar'].should eq 'some tests'
93
- end
94
- end
95
- end
96
- end
97
- end
98
- end
9
+ describe '#interpolate' do
10
+ subject { Raml::Template.new('foo', data, root).interpolate params }
11
+ context 'when the data requires no parameters' do
12
+ let(:params) { {} }
13
+ context 'when its a shallow object' do
14
+ let(:data ) { {'aaa' => 'bbb', 'ccc' => 'ddd', 'eee' => 'fff' } }
15
+ it 'returns the same data that was inputted' do
16
+ subject[1].should eq data
17
+ end
18
+ end
19
+ context 'when its a nested object' do
20
+ let(:data ) { {'aaa' => 'bbb', 'ccc' => [ 'ddd', 'eee' ], 'fff' => { 'ggg' => 'hhh', 'iii' => ['jjj'] } } }
21
+ it 'returns the same data that was inputted' do
22
+ subject[1].should eq data
23
+ end
24
+ end
25
+ end
26
+ context 'when the data requires parameters' do
27
+ context 'when its a shallow object' do
28
+ let(:data ) { {'aaa <<foo>>' => 'bbb', 'ccc' => '<<bar>> ddd', 'eee' => 'fff' } }
29
+ context 'when a required parameter is missing' do
30
+ let(:params) { { 'foo' => 'bar' } }
31
+ it do
32
+ expect { subject }.to raise_exception Raml::UnknownTypeOrTraitParameter
33
+ end
34
+ end
35
+ context 'when all parameters are given' do
36
+ let(:params) { { 'foo' => 'bar', 'bar' => 'baz' } }
37
+ it 'returns the name with the parameter interpolated' do
38
+ subject[1].should eq ({'aaa bar' => 'bbb', 'ccc' => 'baz ddd', 'eee' => 'fff' })
39
+ end
40
+ end
41
+ end
42
+ context 'when its a nested object' do
43
+ let(:data ) { {'aaa <<foo>>' => 'bbb', 'ccc' => [ '<<bar>> ddd', 'eee' ], 'fff' => { 'ggg' => 'hhh', '<<baz>> iii' => ['<<jaz>> jjj'] } } }
44
+ context 'when a required parameter is missing' do
45
+ let(:params) { { 'foo' => 'bar' } }
46
+ it do
47
+ expect { subject }.to raise_exception Raml::UnknownTypeOrTraitParameter
48
+ end
49
+ end
50
+ context 'when all parameters are given' do
51
+ let(:params) { { 'foo' => 'bar', 'bar' => 'baz', 'baz' => 'jaz', 'jaz' => 'max' } }
52
+ it 'returns the name with the parameter interpolated' do
53
+ subject[1].should eq ({'aaa bar' => 'bbb', 'ccc' => [ 'baz ddd', 'eee' ], 'fff' => { 'ggg' => 'hhh', 'jaz iii' => ['max jjj'] } })
54
+ end
55
+ end
56
+ end
57
+ end
58
+ context 'when function parameters are used' do
59
+ context 'when the function is not known' do
60
+ let(:params) { {'some_param' => 'test'} }
61
+ let(:data ) { {'bar' => '<<some_param | !unknown>>'} }
62
+ it do
63
+ expect { subject }.to raise_exception Raml::UnknownTypeOrTraitParamFunction
64
+ end
65
+ end
66
+ context 'when the function is singularize' do
67
+ let(:data) { {'bar' => 'some <<some_param | !singularize>>'} }
68
+ context 'when the parameter is plural' do
69
+ let(:params) { {'some_param' => 'tests'} }
70
+ it 'signularizes it' do
71
+ subject[1]['bar'].should eq 'some test'
72
+ end
73
+ end
74
+ context 'when the parameter is singular' do
75
+ let(:params) { {'some_param' => 'test'} }
76
+ it 'keeps it singular' do
77
+ subject[1]['bar'].should eq 'some test'
78
+ end
79
+ end
80
+ end
81
+ context 'when the function is pluralize' do
82
+ let(:data) { {'bar' => 'some <<some_param | !pluralize>>'} }
83
+ context 'when the parameter is singular' do
84
+ let(:params) { {'some_param' => 'test'} }
85
+ it 'pluralizes it' do
86
+ subject[1]['bar'].should eq 'some tests'
87
+ end
88
+ end
89
+ context 'when the parameter is plural' do
90
+ let(:params) { {'some_param' => 'tests'} }
91
+ it 'keeps it plural' do
92
+ subject[1]['bar'].should eq 'some tests'
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
@@ -1,7 +1,7 @@
1
1
  require_relative 'spec_helper'
2
2
 
3
3
  describe Raml::Trait do
4
- let(:name) { 'secured' }
4
+ let(:name) { 'secured' }
5
5
  let(:data) {
6
6
  YAML.load(%q(
7
7
  usage: Apply this to any method that needs to be secured
@@ -19,13 +19,13 @@ describe Raml::Trait do
19
19
  subject { Raml::Trait.new name, data, root }
20
20
 
21
21
  describe '#new' do
22
- context 'when the trait name is not an HTTP method name' do
22
+ context 'when the trait name is not an HTTP method name' do
23
23
  it { expect { subject }.to_not raise_error }
24
24
  end
25
25
  context 'when the usage property is given' do
26
- it 'stores the usage property' do
27
- subject.instantiate({}).usage.should eq data['usage']
28
- end
29
- end
26
+ it 'stores the usage property' do
27
+ subject.instantiate({}).usage.should eq data['usage']
28
+ end
29
+ end
30
30
  end
31
- end
31
+ end