apipie-rails 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -0
  3. data/.rubocop_todo.yml +22 -99
  4. data/CHANGELOG.md +11 -0
  5. data/apipie-rails.gemspec +1 -0
  6. data/lib/apipie/error_description.rb +7 -5
  7. data/lib/apipie/extractor/recorder.rb +3 -3
  8. data/lib/apipie/extractor/writer.rb +6 -6
  9. data/lib/apipie/generator/swagger/param_description/in.rb +1 -1
  10. data/lib/apipie/generator/swagger/type_extractor.rb +1 -1
  11. data/lib/apipie/generator/swagger/warning.rb +2 -2
  12. data/lib/apipie/helpers.rb +1 -1
  13. data/lib/apipie/response_description.rb +10 -5
  14. data/lib/apipie/routes_formatter.rb +1 -1
  15. data/lib/apipie/version.rb +1 -1
  16. data/lib/tasks/apipie.rake +4 -4
  17. data/spec/controllers/api/v1/architectures_controller_spec.rb +3 -3
  18. data/spec/controllers/api/v2/nested/resources_controller_spec.rb +1 -1
  19. data/spec/controllers/concerns_controller_spec.rb +2 -2
  20. data/spec/controllers/extended_controller_spec.rb +2 -2
  21. data/spec/controllers/included_param_group_controller_spec.rb +1 -1
  22. data/spec/controllers/users_controller_spec.rb +64 -63
  23. data/spec/dummy/app/controllers/extending_concern.rb +7 -7
  24. data/spec/dummy/app/controllers/pets_controller.rb +4 -4
  25. data/spec/dummy/app/controllers/pets_using_auto_views_controller.rb +2 -2
  26. data/spec/dummy/app/controllers/pets_using_self_describing_classes_controller.rb +16 -16
  27. data/spec/dummy/app/controllers/sample_controller.rb +31 -31
  28. data/spec/lib/apipie/application_spec.rb +2 -2
  29. data/spec/lib/apipie/extractor/writer_spec.rb +8 -8
  30. data/spec/lib/apipie/method_description_spec.rb +2 -2
  31. data/spec/lib/apipie/param_description_spec.rb +47 -47
  32. data/spec/lib/apipie/param_group_spec.rb +4 -4
  33. data/spec/lib/apipie/resource_description_spec.rb +2 -2
  34. data/spec/lib/apipie/validator_spec.rb +12 -12
  35. data/spec/lib/swagger/swagger_dsl_spec.rb +40 -40
  36. data/spec/test_engine/memes_controller_spec.rb +1 -1
  37. metadata +138 -4
@@ -28,7 +28,7 @@ describe UsersController do
28
28
  Apipie.get_resource_description(UsersController, Apipie.configuration.default_version)
29
29
  end
30
30
 
31
- it "should contain all resource methods" do
31
+ it "contains all resource methods" do
32
32
  methods = subject._methods
33
33
  expect(methods.keys).to include(:show)
34
34
  expect(methods.keys).to include(:create_route)
@@ -40,7 +40,7 @@ describe UsersController do
40
40
  expect(methods.keys).to include(:multiple_required_params)
41
41
  end
42
42
 
43
- it "should contain info about resource" do
43
+ it "contains info about resource" do
44
44
  expect(subject._short_description).to eq('Site members')
45
45
  expect(subject._id).to eq('users')
46
46
  expect(subject._path).to eq('/users')
@@ -49,7 +49,7 @@ describe UsersController do
49
49
  expect(subject._formats).to eq(['json'])
50
50
  end
51
51
 
52
- it "should contain params defined on resource level" do
52
+ it "contains params defined on resource level" do
53
53
  expect(subject._params_args.count).to eq(2)
54
54
  name, type, options = subject._params_args.first
55
55
  expect(name).to eq(:id)
@@ -67,12 +67,12 @@ describe UsersController do
67
67
  Apipie.configuration.validate_presence = true
68
68
  end
69
69
 
70
- it "should reply to valid request" do
70
+ it "replies to valid request" do
71
71
  get :show, :params => { :id => '5', :session => "secret_hash" }
72
72
  assert_response :success
73
73
  end
74
74
 
75
- it "should pass if required parameter is missing" do
75
+ it "passes if required parameter is missing" do
76
76
  expect { get :show, :params => { :id => 5 } }.not_to raise_error
77
77
  end
78
78
 
@@ -93,20 +93,20 @@ describe UsersController do
93
93
  Apipie.configuration.validate_key = false
94
94
  end
95
95
 
96
- it "should reply to valid request" do
96
+ it "replies to valid request" do
97
97
  expect { get :show, :params => { :id => 5, :session => "secret_hash" }}.not_to raise_error
98
98
  assert_response :success
99
99
  end
100
100
 
101
- it "should fail if required parameter is missing" do
101
+ it "fails if required parameter is missing" do
102
102
  expect { get :show, :params => { :id => 5 }}.to raise_error(Apipie::ParamMissing, /session_parameter_is_required/)
103
103
  end
104
104
 
105
- it "should fail if multiple required parameters are missing" do
105
+ it "fails if multiple required parameters are missing" do
106
106
  expect { get :multiple_required_params }.to raise_error(Apipie::ParamMultipleMissing, /required_param1.*\n.*required_param2|required_param2.*\n.*required_parameter1/)
107
107
  end
108
108
 
109
- it "should pass if required parameter has wrong type" do
109
+ it "passes if required parameter has wrong type" do
110
110
  expect { get :show, :params => { :id => 5 , :session => "secret_hash" }}.not_to raise_error
111
111
  expect { get :show, :params => { :id => "ten" , :session => "secret_hash" }}.not_to raise_error
112
112
  end
@@ -120,12 +120,12 @@ describe UsersController do
120
120
  Apipie.configuration.validate_key = true
121
121
  end
122
122
 
123
- it "should reply to valid request" do
123
+ it "replies to valid request" do
124
124
  expect { get :show, :params => { :id => 5, :session => 'secret_hash' }}.not_to raise_error
125
125
  assert_response :success
126
126
  end
127
127
 
128
- it "should fail if extra parameter is passed in" do
128
+ it "fails if extra parameter is passed in" do
129
129
  expect { get :show, :params => { :id => 5 , :badparam => 'badfoo', :session => "secret_hash" }}.to raise_error(Apipie::UnknownParam, /\bbadparam\b/)
130
130
  end
131
131
  end
@@ -138,12 +138,12 @@ describe UsersController do
138
138
  Apipie.configuration.action_on_non_validated_keys = :skip
139
139
  end
140
140
 
141
- it "should reply to valid request" do
141
+ it "replies to valid request" do
142
142
  expect { get :show, :params => { :id => 5, :session => 'secret_hash' }}.not_to raise_error
143
143
  assert_response :success
144
144
  end
145
145
 
146
- it "should delete the param and not fail if an extra parameter is passed." do
146
+ it "deletes the param and not fail if an extra parameter is passed." do
147
147
  expect { get :show, :params => { :id => 5 , :badparam => 'badfoo', :session => "secret_hash" }}.not_to raise_error
148
148
  expect(controller.params.as_json).to eq({"session"=>"secret_hash", "id"=>"5", "controller"=>"users", "action"=>"show"})
149
149
  end
@@ -160,41 +160,42 @@ describe UsersController do
160
160
  Apipie.configuration.validate_key = false
161
161
  end
162
162
 
163
- it "should reply to valid request" do
163
+ it "replies to valid request" do
164
164
  get :show, :params => { :id => '5', :session => "secret_hash" }
165
165
  assert_response :success
166
166
  end
167
167
 
168
- it "should work with nil value for a required hash param" do
169
- expect {
168
+ it "works with nil value for a required hash param" do
169
+ expect do
170
170
  get :show, :params => { :id => '5', :session => "secret_hash", :hash_param => {:dummy_hash => nil} }
171
- }.to raise_error(Apipie::ParamInvalid, /dummy_hash/)
171
+ end.to raise_error(Apipie::ParamInvalid, /dummy_hash/)
172
172
  assert_response :success
173
173
  end
174
174
 
175
- it "should fail if required parameter is missing" do
175
+ it "fails if required parameter is missing" do
176
176
  expect { get :show, :params => { :id => 5 }}.to raise_error(Apipie::ParamMissing, /session_parameter_is_required/)
177
177
  end
178
178
 
179
- it "should work with custom Type validator" do
180
- expect {
179
+ # old-style error rather than ParamInvalid
180
+ it "works with custom Type validator" do
181
+ expect do
181
182
  get :show,
182
183
  :params => { :id => "not a number", :session => "secret_hash" }
183
- }.to raise_error(Apipie::ParamError, /id/) # old-style error rather than ParamInvalid
184
+ end.to raise_error(Apipie::ParamError, /id/)
184
185
  end
185
186
 
186
- it "should work with Regexp validator" do
187
+ it "works with Regexp validator" do
187
188
  get :show, :params => { :id => 5, :session => "secret_hash", :regexp_param => "24 years" }
188
189
  assert_response :success
189
190
 
190
- expect {
191
+ expect do
191
192
  get :show, :params => { :id => 5,
192
193
  :session => "secret_hash",
193
194
  :regexp_param => "ten years" }
194
- }.to raise_error(Apipie::ParamInvalid, /regexp_param/)
195
+ end.to raise_error(Apipie::ParamInvalid, /regexp_param/)
195
196
  end
196
197
 
197
- it "should work with Array validator" do
198
+ it "works with Array validator" do
198
199
  get :show, :params => { :id => 5, :session => "secret_hash", :array_param => "one" }
199
200
  assert_response :success
200
201
  get :show, :params => { :id => 5, :session => "secret_hash", :array_param => "two" }
@@ -202,28 +203,28 @@ describe UsersController do
202
203
  get :show, :params => { :id => 5, :session => "secret_hash", :array_param => '1' }
203
204
  assert_response :success
204
205
 
205
- expect {
206
+ expect do
206
207
  get :show, :params => { :id => 5,
207
208
  :session => "secret_hash",
208
209
  :array_param => "blabla" }
209
- }.to raise_error(Apipie::ParamInvalid, /array_param/)
210
+ end.to raise_error(Apipie::ParamInvalid, /array_param/)
210
211
 
211
- expect {
212
+ expect do
212
213
  get :show, :params => {
213
214
  :id => 5,
214
215
  :session => "secret_hash",
215
216
  :array_param => 3 }
216
- }.to raise_error(Apipie::ParamInvalid, /array_param/)
217
+ end.to raise_error(Apipie::ParamInvalid, /array_param/)
217
218
  end
218
219
 
219
- it "should work with Proc validator" do
220
- expect {
220
+ it "works with Proc validator" do
221
+ expect do
221
222
  get :show,
222
223
  :params => {
223
224
  :id => 5,
224
225
  :session => "secret_hash",
225
226
  :proc_param => "asdgsag" }
226
- }.to raise_error(Apipie::ParamInvalid, /proc_param/)
227
+ end.to raise_error(Apipie::ParamInvalid, /proc_param/)
227
228
 
228
229
  get :show,
229
230
  :params => {
@@ -233,7 +234,7 @@ describe UsersController do
233
234
  assert_response :success
234
235
  end
235
236
 
236
- it "should work with Hash validator" do
237
+ it "works with Hash validator" do
237
238
  post :create, params: { :user => { :name => "root", :pass => "12345", :membership => "standard" } }
238
239
  assert_response :success
239
240
 
@@ -247,28 +248,28 @@ describe UsersController do
247
248
  hash_params[1].name == :pass
248
249
  hash_params[2].name == :membership
249
250
 
250
- expect {
251
+ expect do
251
252
  post :create, :params => { :user => { :name => "root", :pass => "12345", :membership => "____" } }
252
- }.to raise_error(Apipie::ParamInvalid, /membership/)
253
+ end.to raise_error(Apipie::ParamInvalid, /membership/)
253
254
 
254
255
  # Should include both pass and name
255
- expect {
256
+ expect do
256
257
  post :create, :params => { :user => { :membership => "standard" } }
257
- }.to raise_error(Apipie::ParamMultipleMissing, /pass.*\n.*name|name.*\n.*pass/)
258
+ end.to raise_error(Apipie::ParamMultipleMissing, /pass.*\n.*name|name.*\n.*pass/)
258
259
 
259
- expect {
260
+ expect do
260
261
  post :create, :params => { :user => { :name => "root" } }
261
- }.to raise_error(Apipie::ParamMissing, /pass/)
262
+ end.to raise_error(Apipie::ParamMissing, /pass/)
262
263
 
263
- expect {
264
+ expect do
264
265
  post :create, :params => { :user => "a string is not a hash" }
265
- }.to raise_error(Apipie::ParamInvalid, /user/)
266
+ end.to raise_error(Apipie::ParamInvalid, /user/)
266
267
 
267
268
  post :create, :params => { :user => { :name => "root", :pass => "pwd" } }
268
269
  assert_response :success
269
270
  end
270
271
 
271
- it "should support Hash validator without specifying keys" do
272
+ it "supports Hash validator without specifying keys" do
272
273
  params = Apipie[UsersController, :create].to_json[:params]
273
274
  expect(params).to include(:name => "facts",
274
275
  :full_name => "facts",
@@ -284,7 +285,7 @@ describe UsersController do
284
285
  :validations => [])
285
286
  end
286
287
 
287
- it "should allow nil when allow_nil is set to true" do
288
+ it "allows nil when allow_nil is set to true" do
288
289
  post :create,
289
290
  :params => {
290
291
  :user => {
@@ -297,7 +298,7 @@ describe UsersController do
297
298
  assert_response :success
298
299
  end
299
300
 
300
- it "should allow blank when allow_blank is set to true" do
301
+ it "allows blank when allow_blank is set to true" do
301
302
  post :create,
302
303
  :params => {
303
304
  :user => {
@@ -313,7 +314,7 @@ describe UsersController do
313
314
  describe "nested elements" do
314
315
 
315
316
  context "with valid input" do
316
- it "should succeed" do
317
+ it "succeeds" do
317
318
  put :update,
318
319
  :params => {
319
320
  :id => 5,
@@ -335,8 +336,8 @@ describe UsersController do
335
336
  end
336
337
  end
337
338
  context "with bad input" do
338
- it "should raise an error" do
339
- expect{
339
+ it "raises an error" do
340
+ expect do
340
341
  put :update,
341
342
  :params => {
342
343
  :id => 5,
@@ -353,10 +354,10 @@ describe UsersController do
353
354
  }
354
355
  ]
355
356
  }
356
- }.to raise_error(Apipie::ParamInvalid)
357
+ end.to raise_error(Apipie::ParamInvalid)
357
358
  end
358
359
  end
359
- it "should work with empty array" do
360
+ it "works with empty array" do
360
361
  put :update,
361
362
  :params => {
362
363
  :id => 5,
@@ -407,7 +408,7 @@ describe UsersController do
407
408
 
408
409
  describe "method description" do
409
410
 
410
- it "should contain basic info about method" do
411
+ it "contains basic info about method" do
411
412
  a = Apipie[UsersController, :create]
412
413
  expect(a.apis.count).to eq(1)
413
414
  expect(a.formats).to eq(['json'])
@@ -431,7 +432,7 @@ describe UsersController do
431
432
  end
432
433
 
433
434
  context "Using routes.rb" do
434
- it "should contain basic info about method" do
435
+ it "contains basic info about method" do
435
436
  a = Apipie[UsersController, :create_route]
436
437
  expect(a.apis.count).to eq(1)
437
438
  expect(a.formats).to eq(['json'])
@@ -446,7 +447,7 @@ describe UsersController do
446
447
  context "contain :see option" do
447
448
 
448
449
  context "the key is valid" do
449
- it "should contain reference to another method" do
450
+ it "contains reference to another method" do
450
451
  api = Apipie[UsersController, :see_another]
451
452
  expect(api.show).to be false
452
453
  see = api.see.first
@@ -464,18 +465,18 @@ describe UsersController do
464
465
  end
465
466
 
466
467
  context "the key is not valid" do
467
- it "should raise exception" do
468
+ it "raises exception" do
468
469
  api = Apipie[UsersController, :see_another]
469
470
  api.instance_variable_set :@see, [Apipie::SeeDescription.new(['doesnot#exist'])]
470
- expect {
471
+ expect do
471
472
  api.see.first.see_url
472
- }.to raise_error(ArgumentError, /does not exist/)
473
+ end.to raise_error(ArgumentError, /does not exist/)
473
474
  api.instance_variable_set :@see, []
474
475
  end
475
476
  end
476
477
  end
477
478
 
478
- it "should contain possible errors description" do
479
+ it "contains possible errors description" do
479
480
  a = Apipie.get_method_description(UsersController, :show)
480
481
 
481
482
  expect(a.errors[0].code).to eq(500)
@@ -486,7 +487,7 @@ describe UsersController do
486
487
  expect(a.errors[2].description).to eq("Not Found")
487
488
  end
488
489
 
489
- it 'should recognize Rack symbols as error codes' do
490
+ it 'recognizes Rack symbols as error codes' do
490
491
  a = Apipie.get_method_description(UsersController, :create)
491
492
 
492
493
  error = a.errors.find { |e| e.code == 422 }
@@ -494,7 +495,7 @@ describe UsersController do
494
495
  expect(error.description).to include("Unprocessable Entity")
495
496
  end
496
497
 
497
- it "should contain all params description" do
498
+ it "contains all params description" do
498
499
  a = Apipie.get_method_description(UsersController, :show)
499
500
  expect(a.params.count).to eq(12)
500
501
  expect(a.instance_variable_get('@params_ordered').count).to eq(10)
@@ -564,7 +565,7 @@ describe UsersController do
564
565
  end
565
566
  end
566
567
 
567
- it "should contain all api method description" do
568
+ it "contains all api method description" do
568
569
  method_description = Apipie[UsersController, :two_urls]
569
570
  expect(method_description.class).to be(Apipie::MethodDescription)
570
571
  expect(method_description.apis.count).to eq(2)
@@ -579,7 +580,7 @@ describe UsersController do
579
580
  expect(a2.http_method).to eq('GET')
580
581
  end
581
582
 
582
- it "should be described by valid json" do
583
+ it "is described by valid json" do
583
584
  json = Apipie[UsersController, :two_urls].to_json
584
585
  expected_hash = {
585
586
  :errors => [{:code=>404, :description=>"Missing", :metadata => {:some => "metadata"}},
@@ -672,7 +673,7 @@ describe UsersController do
672
673
 
673
674
  describe "examples" do
674
675
 
675
- it "should be able to load examples from yml file" do
676
+ it "is able to load examples from yml file" do
676
677
  expect(Apipie.get_method_description(UsersController, :show).examples).to eq [<<EOS1, <<EOS2].map(&:chomp)
677
678
  GET /users/14?verbose=true
678
679
  200
@@ -686,7 +687,7 @@ EOS2
686
687
  end
687
688
 
688
689
  describe "document" do
689
- it "should be able to load document from markup file" do
690
+ it "is able to load document from markup file" do
690
691
  expect(Apipie.get_method_description(UsersController, :desc_from_file).full_description).to include("description from document")
691
692
  end
692
693
  end
@@ -694,7 +695,7 @@ EOS2
694
695
 
695
696
  describe "param description" do
696
697
 
697
- it "should contain all specified information" do
698
+ it "contains all specified information" do
698
699
  a = Apipie.get_method_description(UsersController, :show)
699
700
 
700
701
  param = a.params[:session]
@@ -1,10 +1,10 @@
1
- module ExtendingConcern
2
- extend Apipie::DSL::Concern
1
+ module ExtendingConcern
2
+ extend Apipie::DSL::Concern
3
3
 
4
- update_api(:create) do
5
- param :user, Hash do
6
- param :from_concern, String, :desc => 'param from concern', :allow_nil => false
7
- end
8
- meta metadata: 'data'
4
+ update_api(:create) do
5
+ param :user, Hash do
6
+ param :from_concern, String, :desc => 'param from concern', :allow_nil => false
9
7
  end
8
+ meta metadata: 'data'
10
9
  end
10
+ end
@@ -364,8 +364,8 @@ class PetsController < ApplicationController
364
364
  result = {
365
365
  a_number: 3,
366
366
  array_of_objects: [
367
- {number1: 1, number2: 2},
368
- {number1: 10, number2: 20}
367
+ {number1: 1, number2: 2},
368
+ {number1: 10, number2: 20}
369
369
  ]
370
370
  }
371
371
  render :json => result
@@ -387,8 +387,8 @@ class PetsController < ApplicationController
387
387
  result = {
388
388
  a_number: 3,
389
389
  array_of_objects: [
390
- {number1: 1, number2: 2},
391
- {number1: 10, number2: "this should have been a number"}
390
+ {number1: 1, number2: 2},
391
+ {number1: 10, number2: "this should have been a number"}
392
392
  ]
393
393
  }
394
394
  render :json => result
@@ -22,11 +22,11 @@ class SelfDocumentingView
22
22
  # self.describe_own_properties (a class method) generates the meta-data
23
23
  # (i.e., the type description) for the subclass.
24
24
  def self.describe_own_properties
25
- (self.instance_methods - self.class.instance_methods).map{|m|
25
+ (self.instance_methods - self.class.instance_methods).map do |m|
26
26
  if matchdata = /^v_(\w+)__(\w+)$/.match(m)
27
27
  Apipie::prop(matchdata[1], matchdata[2])
28
28
  end
29
- }.compact
29
+ end.compact
30
30
  end
31
31
 
32
32
  # to_json (an instance method) generates the actual view
@@ -13,9 +13,9 @@
13
13
  class Pet
14
14
  def self.describe_own_properties
15
15
  [
16
- Apipie::prop(:pet_name, 'string', {:description => 'Name of pet', :required => false}),
17
- Apipie::prop(:animal_type, 'string', {:description => 'Type of pet', :values => %w[dog cat iguana kangaroo]}),
18
- Apipie::additional_properties(false)
16
+ Apipie::prop(:pet_name, 'string', {:description => 'Name of pet', :required => false}),
17
+ Apipie::prop(:animal_type, 'string', {:description => 'Type of pet', :values => %w[dog cat iguana kangaroo]}),
18
+ Apipie::additional_properties(false)
19
19
  ]
20
20
  end
21
21
  end
@@ -26,14 +26,14 @@ end
26
26
  class PetWithMeasurements
27
27
  def self.describe_own_properties
28
28
  [
29
- Apipie::prop(:pet_name, 'string', {:description => 'Name of pet', :required => false}),
30
- Apipie::prop('animal_type', 'string', {:description => 'Type of pet', :values => %w[dog cat iguana kangaroo]}),
31
- Apipie::prop(:pet_measurements, 'object', {}, [
32
- Apipie::prop(:weight, 'number', {:description => "Weight in pounds" }),
33
- Apipie::prop(:height, 'number', {:description => "Height in inches" }),
34
- Apipie::prop(:num_legs, 'number', {:description => "Number of legs", :required => false }),
35
- Apipie::additional_properties(false)
36
- ])
29
+ Apipie::prop(:pet_name, 'string', {:description => 'Name of pet', :required => false}),
30
+ Apipie::prop('animal_type', 'string', {:description => 'Type of pet', :values => %w[dog cat iguana kangaroo]}),
31
+ Apipie::prop(:pet_measurements, 'object', {}, [
32
+ Apipie::prop(:weight, 'number', {:description => "Weight in pounds" }),
33
+ Apipie::prop(:height, 'number', {:description => "Height in inches" }),
34
+ Apipie::prop(:num_legs, 'number', {:description => "Number of legs", :required => false }),
35
+ Apipie::additional_properties(false)
36
+ ])
37
37
  ]
38
38
  end
39
39
  end
@@ -44,11 +44,11 @@ end
44
44
  class PetWithManyMeasurements
45
45
  def self.describe_own_properties
46
46
  [
47
- Apipie::prop(:pet_name, 'string', {:description => 'Name of pet', :required => false}),
48
- Apipie::prop(:many_pet_measurements, 'object', {is_array: true}, [
49
- Apipie::prop(:weight, 'number', {:description => "Weight in pounds" }),
50
- Apipie::prop(:height, 'number', {:description => "Height in inches" }),
51
- ])
47
+ Apipie::prop(:pet_name, 'string', {:description => 'Name of pet', :required => false}),
48
+ Apipie::prop(:many_pet_measurements, 'object', {is_array: true}, [
49
+ Apipie::prop(:weight, 'number', {:description => "Weight in pounds" }),
50
+ Apipie::prop(:height, 'number', {:description => "Height in inches" }),
51
+ ])
52
52
  ]
53
53
  end
54
54
  end
@@ -1,39 +1,39 @@
1
- module SampleController
2
- extend Apipie::DSL::Concern
1
+ module SampleController
2
+ extend Apipie::DSL::Concern
3
3
 
4
- api!
5
- def index
6
- render :plain => "OK #{params.inspect}"
7
- end
4
+ api!
5
+ def index
6
+ render :plain => "OK #{params.inspect}"
7
+ end
8
8
 
9
- api :GET, '/:resource_id/:id'
10
- param :id, String
11
- def show
12
- render :plain => "OK #{params.inspect}"
13
- end
9
+ api :GET, '/:resource_id/:id'
10
+ param :id, String
11
+ def show
12
+ render :plain => "OK #{params.inspect}"
13
+ end
14
14
 
15
- def_param_group :concern do
16
- param :concern, Hash, :required => true, :action_aware => true do
17
- param :name, String, "Name of a :concern"
18
- param :concern_type, String
19
- end
15
+ def_param_group :concern do
16
+ param :concern, Hash, :required => true, :action_aware => true do
17
+ param :name, String, "Name of a :concern"
18
+ param :concern_type, String
20
19
  end
20
+ end
21
21
 
22
- api :POST, '/:resource_id', "Create a :concern"
23
- param_group :concern
24
- def create
25
- render :plain => "OK #{params.inspect}"
26
- end
22
+ api :POST, '/:resource_id', "Create a :concern"
23
+ param_group :concern
24
+ def create
25
+ render :plain => "OK #{params.inspect}"
26
+ end
27
27
 
28
- api :PUT, '/:resource_id/:id'
29
- param :id, String
30
- param_group :concern
31
- def update
32
- render :plain => "OK #{params.inspect}"
33
- end
28
+ api :PUT, '/:resource_id/:id'
29
+ param :id, String
30
+ param_group :concern
31
+ def update
32
+ render :plain => "OK #{params.inspect}"
33
+ end
34
34
 
35
- api :GET, '/:resource_id/:custom_subst'
36
- def custom
37
- render :plain => "OK #{params.inspect}"
38
- end
35
+ api :GET, '/:resource_id/:custom_subst'
36
+ def custom
37
+ render :plain => "OK #{params.inspect}"
39
38
  end
39
+ end
@@ -8,7 +8,7 @@ describe Apipie::Application do
8
8
  File.join(Rails.root, "lib", "**","*.rb")]
9
9
  end
10
10
 
11
- it "should support receiving array as parameter" do
11
+ it "supports receiving array as parameter" do
12
12
  expect { Apipie.api_controllers_paths}.
13
13
  not_to raise_error
14
14
  end
@@ -33,7 +33,7 @@ describe Apipie::Application do
33
33
  context "with an undefined base url" do
34
34
  let(:base_url) { nil }
35
35
 
36
- it "should not raise an error" do
36
+ it "does not raise an error" do
37
37
  expect { method_call }.not_to raise_error
38
38
  end
39
39
  end
@@ -6,7 +6,7 @@ describe Apipie::Extractor::Writer do
6
6
  let(:writer_class) { Apipie::Extractor::Writer }
7
7
  let(:writer) { writer_class.new(collector) }
8
8
  let(:test_examples_file) { File.join(Rails.root, "doc", "apipie_examples_test.json") }
9
- let(:records) {
9
+ let(:records) do
10
10
  {
11
11
  "concern_resources#show" =>
12
12
  [{
@@ -31,8 +31,8 @@ describe Apipie::Extractor::Writer do
31
31
  :code=>"200"
32
32
  }]
33
33
  }
34
- }
35
- let(:loaded_records) {
34
+ end
35
+ let(:loaded_records) do
36
36
  {
37
37
  "concern_resources#show" =>
38
38
  [{
@@ -57,7 +57,7 @@ describe Apipie::Extractor::Writer do
57
57
  "recorded"=>true
58
58
  }]
59
59
  }
60
- }
60
+ end
61
61
 
62
62
  context 'with doc_path overridden in configuration' do
63
63
  around(:each) do |example|
@@ -67,7 +67,7 @@ describe Apipie::Extractor::Writer do
67
67
  Apipie.configuration.doc_path = standard_path
68
68
  end
69
69
 
70
- it 'should use the doc_path specified in configuration' do
70
+ it 'uses the doc_path specified in configuration' do
71
71
  expect(writer_class.examples_file).to eql(File.join(Rails.root, 'tmp', 'user_specified_doc_path', 'apipie_examples.json'))
72
72
  end
73
73
  end
@@ -80,13 +80,13 @@ describe Apipie::Extractor::Writer do
80
80
  Apipie.configuration.compress_examples = nil
81
81
  end
82
82
 
83
- it 'should write to a compressed file' do
83
+ it 'writes to a compressed file' do
84
84
  expect(writer_class.examples_file).to match(/\.gz$/)
85
85
  writer_class.write_recorded_examples(records)
86
86
  expect(File.exist?(writer_class.examples_file))
87
87
  end
88
88
 
89
- it 'should read from a compressed file' do
89
+ it 'reads from a compressed file' do
90
90
  writer_class.write_recorded_examples(records)
91
91
  expected_string = writer_class.send(:serialize_examples, records)
92
92
  expect(writer_class.load_recorded_examples)
@@ -100,7 +100,7 @@ describe Apipie::Extractor::Writer do
100
100
  expect(collector).to receive(:records).and_return(records)
101
101
  end
102
102
 
103
- it "should read and write examples" do
103
+ it "reads and write examples" do
104
104
  writer.write_examples
105
105
  expect(writer.send(:load_recorded_examples)).to eql(loaded_records)
106
106
  end