grape 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grape might be problematic. Click here for more details.

Files changed (42) hide show
  1. data/.yardopts +2 -0
  2. data/CHANGELOG.markdown +19 -0
  3. data/Gemfile +2 -0
  4. data/README.markdown +166 -131
  5. data/Rakefile +1 -3
  6. data/lib/grape.rb +0 -3
  7. data/lib/grape/api.rb +16 -4
  8. data/lib/grape/cookies.rb +32 -30
  9. data/lib/grape/endpoint.rb +25 -11
  10. data/lib/grape/entity.rb +5 -0
  11. data/lib/grape/error_formatter/base.rb +2 -1
  12. data/lib/grape/middleware/base.rb +9 -2
  13. data/lib/grape/middleware/error.rb +11 -11
  14. data/lib/grape/middleware/formatter.rb +8 -5
  15. data/lib/grape/middleware/versioner/header.rb +1 -3
  16. data/lib/grape/middleware/versioner/path.rb +15 -2
  17. data/lib/grape/util/deep_merge.rb +4 -4
  18. data/lib/grape/validations.rb +2 -3
  19. data/lib/grape/version.rb +1 -1
  20. data/spec/grape/api_spec.rb +316 -175
  21. data/spec/grape/endpoint_spec.rb +159 -57
  22. data/spec/grape/entity_spec.rb +80 -80
  23. data/spec/grape/middleware/auth/basic_spec.rb +3 -3
  24. data/spec/grape/middleware/auth/digest_spec.rb +4 -4
  25. data/spec/grape/middleware/auth/oauth2_spec.rb +4 -4
  26. data/spec/grape/middleware/base_spec.rb +9 -9
  27. data/spec/grape/middleware/error_spec.rb +4 -4
  28. data/spec/grape/middleware/exception_spec.rb +13 -13
  29. data/spec/grape/middleware/formatter_spec.rb +25 -25
  30. data/spec/grape/middleware/versioner/header_spec.rb +23 -23
  31. data/spec/grape/middleware/versioner/param_spec.rb +8 -8
  32. data/spec/grape/middleware/versioner/path_spec.rb +8 -8
  33. data/spec/grape/middleware/versioner_spec.rb +6 -3
  34. data/spec/grape/util/hash_stack_spec.rb +20 -20
  35. data/spec/grape/validations/presence_spec.rb +1 -1
  36. data/spec/grape/validations/regexp_spec.rb +2 -2
  37. data/spec/grape/validations_spec.rb +4 -4
  38. data/spec/shared/versioning_examples.rb +48 -20
  39. metadata +5 -7
  40. data/.document +0 -5
  41. data/lib/grape/middleware/prefixer.rb +0 -21
  42. data/spec/grape/middleware/prefixer_spec.rb +0 -30
@@ -8,36 +8,36 @@ describe Grape::Entity do
8
8
 
9
9
  describe '.expose' do
10
10
  context 'multiple attributes' do
11
- it 'should be able to add multiple exposed attributes with a single call' do
11
+ it 'is able to add multiple exposed attributes with a single call' do
12
12
  subject.expose :name, :email, :location
13
13
  subject.exposures.size.should == 3
14
14
  end
15
15
 
16
- it 'should set the same options for all exposures passed' do
16
+ it 'sets the same options for all exposures passed' do
17
17
  subject.expose :name, :email, :location, :foo => :bar
18
18
  subject.exposures.values.each{|v| v.should == {:foo => :bar}}
19
19
  end
20
20
  end
21
21
 
22
22
  context 'option validation' do
23
- it 'should make sure that :as only works on single attribute calls' do
23
+ it 'makes sure that :as only works on single attribute calls' do
24
24
  expect{ subject.expose :name, :email, :as => :foo }.to raise_error(ArgumentError)
25
25
  expect{ subject.expose :name, :as => :foo }.not_to raise_error
26
26
  end
27
27
 
28
- it 'should make sure that :format_with as a proc can not be used with a block' do
28
+ it 'makes sure that :format_with as a proc can not be used with a block' do
29
29
  expect { subject.expose :name, :format_with => Proc.new {} do |_| end }.to raise_error(ArgumentError)
30
30
  end
31
31
  end
32
32
 
33
33
  context 'with a block' do
34
- it 'should error out if called with multiple attributes' do
34
+ it 'errors out if called with multiple attributes' do
35
35
  expect{ subject.expose(:name, :email) do
36
36
  true
37
37
  end }.to raise_error(ArgumentError)
38
38
  end
39
39
 
40
- it 'should set the :proc option in the exposure options' do
40
+ it 'sets the :proc option in the exposure options' do
41
41
  block = lambda{|_| true }
42
42
  subject.expose :name, &block
43
43
  subject.exposures[:name][:proc].should == block
@@ -45,14 +45,14 @@ describe Grape::Entity do
45
45
  end
46
46
 
47
47
  context 'inherited exposures' do
48
- it 'should return exposures from an ancestor' do
48
+ it 'returns exposures from an ancestor' do
49
49
  subject.expose :name, :email
50
50
  child_class = Class.new(subject)
51
51
 
52
52
  child_class.exposures.should eq(subject.exposures)
53
53
  end
54
54
 
55
- it 'should return exposures from multiple ancestor' do
55
+ it 'returns exposures from multiple ancestor' do
56
56
  subject.expose :name, :email
57
57
  parent_class = Class.new(subject)
58
58
  child_class = Class.new(parent_class)
@@ -60,7 +60,7 @@ describe Grape::Entity do
60
60
  child_class.exposures.should eq(subject.exposures)
61
61
  end
62
62
 
63
- it 'should return descendant exposures as a priority' do
63
+ it 'returns descendant exposures as a priority' do
64
64
  subject.expose :name, :email
65
65
  child_class = Class.new(subject)
66
66
  child_class.expose :name do |_|
@@ -75,24 +75,24 @@ describe Grape::Entity do
75
75
  context 'register formatters' do
76
76
  let(:date_formatter) { lambda {|date| date.strftime('%m/%d/%Y') }}
77
77
 
78
- it 'should register a formatter' do
78
+ it 'registers a formatter' do
79
79
  subject.format_with :timestamp, &date_formatter
80
80
 
81
81
  subject.formatters[:timestamp].should_not be_nil
82
82
  end
83
83
 
84
- it 'should inherit formatters from ancestors' do
84
+ it 'inherits formatters from ancestors' do
85
85
  subject.format_with :timestamp, &date_formatter
86
86
  child_class = Class.new(subject)
87
87
 
88
88
  child_class.formatters.should == subject.formatters
89
89
  end
90
90
 
91
- it 'should not allow registering a formatter without a block' do
91
+ it 'does not allow registering a formatter without a block' do
92
92
  expect{ subject.format_with :foo }.to raise_error(ArgumentError)
93
93
  end
94
94
 
95
- it 'should format an exposure with a registered formatter' do
95
+ it 'formats an exposure with a registered formatter' do
96
96
  subject.format_with :timestamp do |date|
97
97
  date.strftime('%m/%d/%Y')
98
98
  end
@@ -106,22 +106,22 @@ describe Grape::Entity do
106
106
  end
107
107
 
108
108
  describe '.represent' do
109
- it 'should return a single entity if called with one object' do
109
+ it 'returns a single entity if called with one object' do
110
110
  subject.represent(Object.new).should be_kind_of(subject)
111
111
  end
112
112
 
113
- it 'should return a single entity if called with a hash' do
113
+ it 'returns a single entity if called with a hash' do
114
114
  subject.represent(Hash.new).should be_kind_of(subject)
115
115
  end
116
116
 
117
- it 'should return multiple entities if called with a collection' do
117
+ it 'returns multiple entities if called with a collection' do
118
118
  representation = subject.represent(4.times.map{Object.new})
119
- representation.should be_kind_of(Array)
119
+ representation.should be_kind_of Array
120
120
  representation.size.should == 4
121
121
  representation.reject{|r| r.kind_of?(subject)}.should be_empty
122
122
  end
123
123
 
124
- it 'should add the :collection => true option if called with a collection' do
124
+ it 'adds the :collection => true option if called with a collection' do
125
125
  representation = subject.represent(4.times.map{Object.new})
126
126
  representation.each{|r| r.options[:collection].should be_true}
127
127
  end
@@ -134,20 +134,20 @@ describe Grape::Entity do
134
134
  end
135
135
 
136
136
  context 'with a single object' do
137
- it 'should allow a root element name to be specified' do
137
+ it 'allows a root element name to be specified' do
138
138
  representation = subject.represent(Object.new)
139
- representation.should be_kind_of(Hash)
140
- representation.should have_key('thing')
139
+ representation.should be_kind_of Hash
140
+ representation.should have_key 'thing'
141
141
  representation['thing'].should be_kind_of(subject)
142
142
  end
143
143
  end
144
144
 
145
145
  context 'with an array of objects' do
146
- it 'should allow a root element name to be specified' do
146
+ it 'allows a root element name to be specified' do
147
147
  representation = subject.represent(4.times.map{Object.new})
148
- representation.should be_kind_of(Hash)
149
- representation.should have_key('things')
150
- representation['things'].should be_kind_of(Array)
148
+ representation.should be_kind_of Hash
149
+ representation.should have_key 'things'
150
+ representation['things'].should be_kind_of Array
151
151
  representation['things'].size.should == 4
152
152
  representation['things'].reject{|r| r.kind_of?(subject)}.should be_empty
153
153
  end
@@ -156,15 +156,15 @@ describe Grape::Entity do
156
156
  context 'it can be overridden' do
157
157
  it 'can be disabled' do
158
158
  representation = subject.represent(4.times.map{Object.new}, :root=>false)
159
- representation.should be_kind_of(Array)
159
+ representation.should be_kind_of Array
160
160
  representation.size.should == 4
161
161
  representation.reject{|r| r.kind_of?(subject)}.should be_empty
162
162
  end
163
163
  it 'can use a different name' do
164
164
  representation = subject.represent(4.times.map{Object.new}, :root=>'others')
165
- representation.should be_kind_of(Hash)
166
- representation.should have_key('others')
167
- representation['others'].should be_kind_of(Array)
165
+ representation.should be_kind_of Hash
166
+ representation.should have_key 'others'
167
+ representation['others'].should be_kind_of Array
168
168
  representation['others'].size.should == 4
169
169
  representation['others'].reject{|r| r.kind_of?(subject)}.should be_empty
170
170
  end
@@ -177,18 +177,18 @@ describe Grape::Entity do
177
177
  end
178
178
 
179
179
  context 'with a single object' do
180
- it 'should allow a root element name to be specified' do
180
+ it 'allows a root element name to be specified' do
181
181
  representation = subject.represent(Object.new)
182
- representation.should be_kind_of(Hash)
183
- representation.should have_key('thing')
182
+ representation.should be_kind_of Hash
183
+ representation.should have_key 'thing'
184
184
  representation['thing'].should be_kind_of(subject)
185
185
  end
186
186
  end
187
187
 
188
188
  context 'with an array of objects' do
189
- it 'should allow a root element name to be specified' do
189
+ it 'allows a root element name to be specified' do
190
190
  representation = subject.represent(4.times.map{Object.new})
191
- representation.should be_kind_of(Array)
191
+ representation.should be_kind_of Array
192
192
  representation.size.should == 4
193
193
  representation.reject{|r| r.kind_of?(subject)}.should be_empty
194
194
  end
@@ -201,17 +201,17 @@ describe Grape::Entity do
201
201
  end
202
202
 
203
203
  context 'with a single object' do
204
- it 'should allow a root element name to be specified' do
204
+ it 'allows a root element name to be specified' do
205
205
  subject.represent(Object.new).should be_kind_of(subject)
206
206
  end
207
207
  end
208
208
 
209
209
  context 'with an array of objects' do
210
- it 'should allow a root element name to be specified' do
210
+ it 'allows a root element name to be specified' do
211
211
  representation = subject.represent(4.times.map{Object.new})
212
- representation.should be_kind_of(Hash)
212
+ representation.should be_kind_of Hash
213
213
  representation.should have_key('things')
214
- representation['things'].should be_kind_of(Array)
214
+ representation['things'].should be_kind_of Array
215
215
  representation['things'].size.should == 4
216
216
  representation['things'].reject{|r| r.kind_of?(subject)}.should be_empty
217
217
  end
@@ -220,13 +220,13 @@ describe Grape::Entity do
220
220
  end
221
221
 
222
222
  describe '#initialize' do
223
- it 'should take an object and an optional options hash' do
223
+ it 'takes an object and an optional options hash' do
224
224
  expect{ subject.new(Object.new) }.not_to raise_error
225
225
  expect{ subject.new }.to raise_error(ArgumentError)
226
226
  expect{ subject.new(Object.new, {}) }.not_to raise_error
227
227
  end
228
228
 
229
- it 'should have attribute readers for the object and options' do
229
+ it 'has attribute readers for the object and options' do
230
230
  entity = subject.new('abc', {})
231
231
  entity.object.should == 'abc'
232
232
  entity.options.should == {}
@@ -253,21 +253,21 @@ describe Grape::Entity do
253
253
 
254
254
  describe '#serializable_hash' do
255
255
 
256
- it 'should not throw an exception if a nil options object is passed' do
256
+ it 'does not throw an exception if a nil options object is passed' do
257
257
  expect{ fresh_class.new(model).serializable_hash(nil) }.not_to raise_error
258
258
  end
259
259
 
260
- it 'should not blow up when the model is nil' do
260
+ it 'does not blow up when the model is nil' do
261
261
  fresh_class.expose :name
262
262
  expect{ fresh_class.new(nil).serializable_hash }.not_to raise_error
263
263
  end
264
264
 
265
- it 'should not throw an exception when an attribute is not found on the object' do
265
+ it 'does not throw an exception when an attribute is not found on the object' do
266
266
  fresh_class.expose :name, :nonexistent_attribute
267
267
  expect{ fresh_class.new(model).serializable_hash }.not_to raise_error
268
268
  end
269
269
 
270
- it "should not expose attributes that don't exist on the object" do
270
+ it "does not expose attributes that don't exist on the object" do
271
271
  fresh_class.expose :email, :nonexistent_attribute, :name
272
272
 
273
273
  res = fresh_class.new(model).serializable_hash
@@ -276,7 +276,7 @@ describe Grape::Entity do
276
276
  res.should have_key :name
277
277
  end
278
278
 
279
- it "should not expose attributes that don't exist on the object, even with criteria" do
279
+ it "does not expose attributes that don't exist on the object, even with criteria" do
280
280
  fresh_class.expose :email
281
281
  fresh_class.expose :nonexistent_attribute, :if => lambda { false }
282
282
  fresh_class.expose :nonexistent_attribute2, :if => lambda { true }
@@ -287,7 +287,7 @@ describe Grape::Entity do
287
287
  res.should_not have_key :nonexistent_attribute2
288
288
  end
289
289
 
290
- it "should expose attributes that don't exist on the object only when they are generated by a block" do
290
+ it "exposes attributes that don't exist on the object only when they are generated by a block" do
291
291
  fresh_class.expose :nonexistent_attribute do |model, _|
292
292
  "well, I do exist after all"
293
293
  end
@@ -295,7 +295,7 @@ describe Grape::Entity do
295
295
  res.should have_key :nonexistent_attribute
296
296
  end
297
297
 
298
- it "should not expose attributes that are generated by a block but have not passed criteria" do
298
+ it "does not expose attributes that are generated by a block but have not passed criteria" do
299
299
  fresh_class.expose :nonexistent_attribute, :proc => lambda {|model, _|
300
300
  "I exist, but it is not yet my time to shine"
301
301
  }, :if => lambda { |model, _| false }
@@ -303,7 +303,7 @@ describe Grape::Entity do
303
303
  res.should_not have_key :nonexistent_attribute
304
304
  end
305
305
 
306
- context "#serializable_hash" do
306
+ context '#serializable_hash' do
307
307
 
308
308
  module EntitySpec
309
309
  class EmbeddedExample
@@ -329,13 +329,13 @@ describe Grape::Entity do
329
329
  end
330
330
  end
331
331
 
332
- it 'should serialize embedded objects which respond to #serializable_hash' do
332
+ it 'serializes embedded objects which respond to #serializable_hash' do
333
333
  fresh_class.expose :name, :embedded
334
334
  presenter = fresh_class.new(EntitySpec::EmbeddedExampleWithOne.new)
335
335
  presenter.serializable_hash.should == {:name => "abc", :embedded => {:abc => "def"}}
336
336
  end
337
337
 
338
- it 'should serialize embedded arrays of objects which respond to #serializable_hash' do
338
+ it 'serializes embedded arrays of objects which respond to #serializable_hash' do
339
339
  fresh_class.expose :name, :embedded
340
340
  presenter = fresh_class.new(EntitySpec::EmbeddedExampleWithMany.new)
341
341
  presenter.serializable_hash.should == {:name => "abc", :embedded => [{:abc => "def"}, {:abc => "def"}]}
@@ -364,11 +364,11 @@ describe Grape::Entity do
364
364
  end
365
365
  end
366
366
 
367
- it 'should pass through bare expose attributes' do
367
+ it 'passes through bare expose attributes' do
368
368
  subject.send(:value_for, :name).should == attributes[:name]
369
369
  end
370
370
 
371
- it 'should instantiate a representation if that is called for' do
371
+ it 'instantiates a representation if that is called for' do
372
372
  rep = subject.send(:value_for, :friends)
373
373
  rep.reject{|r| r.is_a?(fresh_class)}.should be_empty
374
374
  rep.first.serializable_hash[:name].should == 'Friend 1'
@@ -376,7 +376,7 @@ describe Grape::Entity do
376
376
  end
377
377
 
378
378
  context 'child representations' do
379
- it 'should disable root key name for child representations' do
379
+ it 'disables root key name for child representations' do
380
380
 
381
381
  module EntitySpec
382
382
  class FriendEntity < Grape::Entity
@@ -390,13 +390,13 @@ describe Grape::Entity do
390
390
  end
391
391
 
392
392
  rep = subject.send(:value_for, :friends)
393
- rep.should be_kind_of(Array)
393
+ rep.should be_kind_of Array
394
394
  rep.reject{|r| r.is_a?(EntitySpec::FriendEntity)}.should be_empty
395
395
  rep.first.serializable_hash[:name].should == 'Friend 1'
396
396
  rep.last.serializable_hash[:name].should == 'Friend 2'
397
397
  end
398
398
 
399
- it 'should pass through custom options' do
399
+ it 'passes through custom options' do
400
400
  module EntitySpec
401
401
  class FriendEntity < Grape::Entity
402
402
  root 'friends', 'friend'
@@ -410,19 +410,19 @@ describe Grape::Entity do
410
410
  end
411
411
 
412
412
  rep = subject.send(:value_for, :friends)
413
- rep.should be_kind_of(Array)
413
+ rep.should be_kind_of Array
414
414
  rep.reject{|r| r.is_a?(EntitySpec::FriendEntity)}.should be_empty
415
415
  rep.first.serializable_hash[:email].should be_nil
416
416
  rep.last.serializable_hash[:email].should be_nil
417
417
 
418
418
  rep = subject.send(:value_for, :friends, { :user_type => :admin })
419
- rep.should be_kind_of(Array)
419
+ rep.should be_kind_of Array
420
420
  rep.reject{|r| r.is_a?(EntitySpec::FriendEntity)}.should be_empty
421
421
  rep.first.serializable_hash[:email].should == 'friend1@example.com'
422
422
  rep.last.serializable_hash[:email].should == 'friend2@example.com'
423
423
  end
424
424
 
425
- it 'should ignore the :collection parameter in the source options' do
425
+ it 'ignores the :collection parameter in the source options' do
426
426
  module EntitySpec
427
427
  class FriendEntity < Grape::Entity
428
428
  root 'friends', 'friend'
@@ -436,7 +436,7 @@ describe Grape::Entity do
436
436
  end
437
437
 
438
438
  rep = subject.send(:value_for, :friends, { :collection => false })
439
- rep.should be_kind_of(Array)
439
+ rep.should be_kind_of Array
440
440
  rep.reject{|r| r.is_a?(EntitySpec::FriendEntity)}.should be_empty
441
441
  rep.first.serializable_hash[:email].should == 'friend1@example.com'
442
442
  rep.last.serializable_hash[:email].should == 'friend2@example.com'
@@ -444,27 +444,27 @@ describe Grape::Entity do
444
444
 
445
445
  end
446
446
 
447
- it 'should call through to the proc if there is one' do
447
+ it 'calls through to the proc if there is one' do
448
448
  subject.send(:value_for, :computed, :awesome => 123).should == 123
449
449
  end
450
450
 
451
- it 'should return a formatted value if format_with is passed' do
451
+ it 'returns a formatted value if format_with is passed' do
452
452
  subject.send(:value_for, :birthday).should == '02/27/2012'
453
453
  end
454
454
 
455
- it 'should return a formatted value if format_with is passed a lambda' do
455
+ it 'returns a formatted value if format_with is passed a lambda' do
456
456
  subject.send(:value_for, :fantasies).should == ['Nessy', 'Double Rainbows', 'Unicorns']
457
457
  end
458
458
  end
459
459
 
460
460
  describe '#documentation' do
461
- it 'should return an empty hash is no documentation is provided' do
461
+ it 'returns an empty hash is no documentation is provided' do
462
462
  fresh_class.expose :name
463
463
 
464
464
  subject.documentation.should == {}
465
465
  end
466
466
 
467
- it 'should return each defined documentation hash' do
467
+ it 'returns each defined documentation hash' do
468
468
  doc = {:type => "foo", :desc => "bar"}
469
469
  fresh_class.expose :name, :documentation => doc
470
470
  fresh_class.expose :email, :documentation => doc
@@ -475,24 +475,24 @@ describe Grape::Entity do
475
475
  end
476
476
 
477
477
  describe '#key_for' do
478
- it 'should return the attribute if no :as is set' do
478
+ it 'returns the attribute if no :as is set' do
479
479
  fresh_class.expose :name
480
480
  subject.send(:key_for, :name).should == :name
481
481
  end
482
482
 
483
- it 'should return a symbolized version of the attribute' do
483
+ it 'returns a symbolized version of the attribute' do
484
484
  fresh_class.expose :name
485
485
  subject.send(:key_for, 'name').should == :name
486
486
  end
487
487
 
488
- it 'should return the :as alias if one exists' do
488
+ it 'returns the :as alias if one exists' do
489
489
  fresh_class.expose :name, :as => :nombre
490
490
  subject.send(:key_for, 'name').should == :nombre
491
491
  end
492
492
  end
493
493
 
494
494
  describe '#conditions_met?' do
495
- it 'should only pass through hash :if exposure if all attributes match' do
495
+ it 'only passes through hash :if exposure if all attributes match' do
496
496
  exposure_options = {:if => {:condition1 => true, :condition2 => true}}
497
497
 
498
498
  subject.send(:conditions_met?, exposure_options, {}).should be_false
@@ -502,14 +502,14 @@ describe Grape::Entity do
502
502
  subject.send(:conditions_met?, exposure_options, :condition1 => true, :condition2 => true, :other => true).should be_true
503
503
  end
504
504
 
505
- it 'should only pass through proc :if exposure if it returns truthy value' do
505
+ it 'only passes through proc :if exposure if it returns truthy value' do
506
506
  exposure_options = {:if => lambda{|_,opts| opts[:true]}}
507
507
 
508
508
  subject.send(:conditions_met?, exposure_options, :true => false).should be_false
509
509
  subject.send(:conditions_met?, exposure_options, :true => true).should be_true
510
510
  end
511
511
 
512
- it 'should only pass through hash :unless exposure if any attributes do not match' do
512
+ it 'only passes through hash :unless exposure if any attributes do not match' do
513
513
  exposure_options = {:unless => {:condition1 => true, :condition2 => true}}
514
514
 
515
515
  subject.send(:conditions_met?, exposure_options, {}).should be_true
@@ -520,7 +520,7 @@ describe Grape::Entity do
520
520
  subject.send(:conditions_met?, exposure_options, :condition1 => false, :condition2 => false).should be_true
521
521
  end
522
522
 
523
- it 'should only pass through proc :unless exposure if it returns falsy value' do
523
+ it 'only passes through proc :unless exposure if it returns falsy value' do
524
524
  exposure_options = {:unless => lambda{|_,options| options[:true] == true}}
525
525
 
526
526
  subject.send(:conditions_met?, exposure_options, :true => false).should be_true
@@ -528,19 +528,19 @@ describe Grape::Entity do
528
528
  end
529
529
  end
530
530
 
531
- describe "::DSL" do
531
+ describe '::DSL' do
532
532
  subject{ Class.new }
533
533
 
534
- it 'should create an Entity class when called' do
535
- subject.should_not be_const_defined(:Entity)
534
+ it 'creates an Entity class when called' do
535
+ subject.should_not be_const_defined :Entity
536
536
  subject.send(:include, Grape::Entity::DSL)
537
- subject.should be_const_defined(:Entity)
537
+ subject.should be_const_defined :Entity
538
538
  end
539
539
 
540
540
  context 'pre-mixed' do
541
541
  before{ subject.send(:include, Grape::Entity::DSL) }
542
542
 
543
- it 'should be able to define entity traits through DSL' do
543
+ it 'is able to define entity traits through DSL' do
544
544
  subject.entity do
545
545
  expose :name
546
546
  end
@@ -548,12 +548,12 @@ describe Grape::Entity do
548
548
  subject.entity_class.exposures.should_not be_empty
549
549
  end
550
550
 
551
- it 'should be able to expose straight from the class' do
551
+ it 'is able to expose straight from the class' do
552
552
  subject.entity :name, :email
553
553
  subject.entity_class.exposures.size.should == 2
554
554
  end
555
555
 
556
- it 'should be able to mix field and advanced exposures' do
556
+ it 'is able to mix field and advanced exposures' do
557
557
  subject.entity :name, :email do
558
558
  expose :third
559
559
  end
@@ -564,11 +564,11 @@ describe Grape::Entity do
564
564
  let(:instance){ subject.new }
565
565
 
566
566
  describe '#entity' do
567
- it 'should be an instance of the entity class' do
567
+ it 'is an instance of the entity class' do
568
568
  instance.entity.should be_kind_of(subject.entity_class)
569
569
  end
570
570
 
571
- it 'should have an object of itself' do
571
+ it 'has an object of itself' do
572
572
  instance.entity.object.should == instance
573
573
  end
574
574
  end