draper 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,7 @@ module ActiveModel
6
6
  app ||= Rails.application # Rails 3.0.x does not yield `app`
7
7
 
8
8
  Rails::Generators.configure! app.config.generators
9
- require 'generators/resource_override'
9
+ require_relative '../generators/resource_override'
10
10
  end
11
11
  end
12
12
  end
@@ -1,3 +1,3 @@
1
1
  module Draper
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
@@ -27,8 +27,8 @@ module Rails
27
27
 
28
28
  # Rails 3.0.X compatibility, stolen from https://github.com/jnunemaker/mongomapper/pull/385/files#L1R32
29
29
  unless methods.include?(:module_namespacing)
30
- def module_namespacing(&block)
31
- yield if block
30
+ def module_namespacing
31
+ yield if block_given?
32
32
  end
33
33
  end
34
34
  end
@@ -11,7 +11,7 @@ class <%= class_name %>
11
11
  #
12
12
  # def created_at
13
13
  # helpers.content_tag :span, class: 'time' do
14
- # source.created_at.strftime("%a %m/%d/%y")
14
+ # object.created_at.strftime("%a %m/%d/%y")
15
15
  # end
16
16
  # end
17
17
 
@@ -84,8 +84,8 @@ module Draper
84
84
  collection = [Product.new, Product.new]
85
85
  decorator = CollectionDecorator.new(collection)
86
86
 
87
- decorator.zip collection do |item, source|
88
- expect(item.source).to be source
87
+ decorator.zip collection do |item, object|
88
+ expect(item.object).to be object
89
89
  end
90
90
  end
91
91
 
@@ -109,8 +109,8 @@ module Draper
109
109
  describe ".delegate" do
110
110
  protect_class ProductsDecorator
111
111
 
112
- it "defaults the :to option to :source" do
113
- Object.should_receive(:delegate).with(:foo, :bar, to: :source)
112
+ it "defaults the :to option to :object" do
113
+ Object.should_receive(:delegate).with(:foo, :bar, to: :object)
114
114
  ProductsDecorator.delegate :foo, :bar
115
115
  end
116
116
 
@@ -131,12 +131,15 @@ module Draper
131
131
  end
132
132
 
133
133
  context "without a block" do
134
- it "decorates Model.find" do
135
- item_decorator = Class.new
136
- decorator = CollectionDecorator.new([], with: item_decorator)
137
-
138
- item_decorator.should_receive(:find).with(1).and_return(:delegated)
139
- expect(decorator.find(1)).to be :delegated
134
+ it "decorates object.find" do
135
+ object = []
136
+ found = stub(decorate: :decorated)
137
+ decorator = CollectionDecorator.new(object)
138
+
139
+ object.should_receive(:find).and_return(found)
140
+ ActiveSupport::Deprecation.silence do
141
+ expect(decorator.find(1)).to be :decorated
142
+ end
140
143
  end
141
144
  end
142
145
  end
@@ -159,17 +162,17 @@ module Draper
159
162
  end
160
163
 
161
164
  describe "#==" do
162
- context "when comparing to a collection decorator with the same source" do
165
+ context "when comparing to a collection decorator with the same object" do
163
166
  it "returns true" do
164
- source = [Product.new, Product.new]
165
- decorator = CollectionDecorator.new(source)
166
- other = ProductsDecorator.new(source)
167
+ object = [Product.new, Product.new]
168
+ decorator = CollectionDecorator.new(object)
169
+ other = ProductsDecorator.new(object)
167
170
 
168
171
  expect(decorator == other).to be_true
169
172
  end
170
173
  end
171
174
 
172
- context "when comparing to a collection decorator with a different source" do
175
+ context "when comparing to a collection decorator with a different object" do
173
176
  it "returns false" do
174
177
  decorator = CollectionDecorator.new([Product.new, Product.new])
175
178
  other = ProductsDecorator.new([Product.new, Product.new])
@@ -180,9 +183,9 @@ module Draper
180
183
 
181
184
  context "when comparing to a collection of the same items" do
182
185
  it "returns true" do
183
- source = [Product.new, Product.new]
184
- decorator = CollectionDecorator.new(source)
185
- other = source.dup
186
+ object = [Product.new, Product.new]
187
+ decorator = CollectionDecorator.new(object)
188
+ other = object.dup
186
189
 
187
190
  expect(decorator == other).to be_true
188
191
  end
@@ -198,10 +201,10 @@ module Draper
198
201
  end
199
202
 
200
203
  context "when the decorated collection has been modified" do
201
- it "is no longer equal to the source" do
202
- source = [Product.new, Product.new]
203
- decorator = CollectionDecorator.new(source)
204
- other = source.dup
204
+ it "is no longer equal to the object" do
205
+ object = [Product.new, Product.new]
206
+ decorator = CollectionDecorator.new(object)
207
+ other = object.dup
205
208
 
206
209
  decorator << Product.new.decorate
207
210
  expect(decorator == other).to be_false
@@ -275,5 +278,21 @@ module Draper
275
278
  end
276
279
  end
277
280
 
281
+ describe "#replace" do
282
+ it "replaces the decorated collection" do
283
+ decorator = CollectionDecorator.new([Product.new])
284
+ replacement = [:foo, :bar]
285
+
286
+ decorator.replace replacement
287
+ expect(decorator).to match_array replacement
288
+ end
289
+
290
+ it "returns itself" do
291
+ decorator = CollectionDecorator.new([Product.new])
292
+
293
+ expect(decorator.replace([:foo, :bar])).to be decorator
294
+ end
295
+ end
296
+
278
297
  end
279
298
  end
@@ -10,7 +10,7 @@ module Draper
10
10
  decorator = product.decorate
11
11
 
12
12
  expect(decorator).to be_a ProductDecorator
13
- expect(decorator.source).to be product
13
+ expect(decorator.object).to be product
14
14
  end
15
15
 
16
16
  it "accepts context" do
@@ -89,19 +89,19 @@ module Draper
89
89
  end
90
90
 
91
91
  it "is true for a decorated instance" do
92
- decorator = double(source: Product.new)
92
+ decorator = double(object: Product.new)
93
93
 
94
94
  expect(Product === decorator).to be_true
95
95
  end
96
96
 
97
97
  it "is true for a decorated derived instance" do
98
- decorator = double(source: Class.new(Product).new)
98
+ decorator = double(object: Class.new(Product).new)
99
99
 
100
100
  expect(Product === decorator).to be_true
101
101
  end
102
102
 
103
103
  it "is false for a decorated unrelated instance" do
104
- decorator = double(source: Model.new)
104
+ decorator = double(object: Model.new)
105
105
 
106
106
  expect(Product === decorator).to be_false
107
107
  end
@@ -43,8 +43,8 @@ module Draper
43
43
  Factory.stub new: factory
44
44
  associated = double
45
45
  owner_context = {foo: "bar"}
46
- source = double(association: associated)
47
- owner = double(source: source, context: owner_context)
46
+ object = double(association: associated)
47
+ owner = double(object: object, context: owner_context)
48
48
  decorated_association = DecoratedAssociation.new(owner, :association, {})
49
49
  decorated = double
50
50
 
@@ -55,7 +55,7 @@ module Draper
55
55
  it "memoizes" do
56
56
  factory = double
57
57
  Factory.stub new: factory
58
- owner = double(source: double(association: double), context: {})
58
+ owner = double(object: double(association: double), context: {})
59
59
  decorated_association = DecoratedAssociation.new(owner, :association, {})
60
60
  decorated = double
61
61
 
@@ -69,8 +69,8 @@ module Draper
69
69
  factory = double
70
70
  Factory.stub new: factory
71
71
  scoped = double
72
- source = double(association: double(applied_scope: scoped))
73
- owner = double(source: source, context: {})
72
+ object = double(association: double(applied_scope: scoped))
73
+ owner = double(object: object, context: {})
74
74
  decorated_association = DecoratedAssociation.new(owner, :association, scope: :applied_scope)
75
75
  decorated = double
76
76
 
@@ -41,15 +41,15 @@ module Draper
41
41
 
42
42
  describe "the generated method" do
43
43
  it "decorates the instance variable" do
44
- source = double
44
+ object = double
45
45
  factory = double
46
46
  Factory.stub new: factory
47
47
 
48
48
  controller_class.decorates_assigned :article
49
49
  controller = controller_class.new
50
- controller.instance_variable_set "@article", source
50
+ controller.instance_variable_set "@article", object
51
51
 
52
- factory.should_receive(:decorate).with(source, context_args: controller).and_return(:decorated)
52
+ factory.should_receive(:decorate).with(object, context_args: controller).and_return(:decorated)
53
53
  expect(controller.article).to be :decorated
54
54
  end
55
55
 
@@ -17,11 +17,11 @@ module Draper
17
17
  end
18
18
  end
19
19
 
20
- it "sets the source" do
21
- source = Model.new
22
- decorator = Decorator.new(source)
20
+ it "sets the object" do
21
+ object = Model.new
22
+ decorator = Decorator.new(object)
23
23
 
24
- expect(decorator.source).to be source
24
+ expect(decorator.object).to be object
25
25
  end
26
26
 
27
27
  it "stores context" do
@@ -32,12 +32,12 @@ module Draper
32
32
  end
33
33
 
34
34
  context "when decorating an instance of itself" do
35
- it "applies to the source instead" do
36
- source = Model.new
37
- decorated = Decorator.new(source)
35
+ it "applies to the object instead" do
36
+ object = Model.new
37
+ decorated = Decorator.new(object)
38
38
  redecorated = Decorator.new(decorated)
39
39
 
40
- expect(redecorated.source).to be source
40
+ expect(redecorated.object).to be object
41
41
  end
42
42
 
43
43
  context "with context" do
@@ -65,7 +65,7 @@ module Draper
65
65
  decorated = OtherDecorator.new(Model.new)
66
66
  redecorated = Decorator.new(decorated)
67
67
 
68
- expect(redecorated.source).to be decorated
68
+ expect(redecorated.object).to be decorated
69
69
  end
70
70
 
71
71
  context "when it has been applied previously" do
@@ -85,7 +85,7 @@ module Draper
85
85
  Object.any_instance.stub(:warn)
86
86
  redecorated = Decorator.decorate(decorated)
87
87
 
88
- expect(redecorated.source).to be decorated
88
+ expect(redecorated.object).to be decorated
89
89
  end
90
90
  end
91
91
  end
@@ -116,10 +116,10 @@ module Draper
116
116
 
117
117
  context "without a custom collection decorator" do
118
118
  it "creates a CollectionDecorator using itself for each item" do
119
- source = [Model.new]
119
+ object = [Model.new]
120
120
 
121
- CollectionDecorator.should_receive(:new).with(source, with: Decorator)
122
- Decorator.decorate_collection(source)
121
+ CollectionDecorator.should_receive(:new).with(object, with: Decorator)
122
+ Decorator.decorate_collection(object)
123
123
  end
124
124
 
125
125
  it "passes options to the collection decorator" do
@@ -132,10 +132,10 @@ module Draper
132
132
 
133
133
  context "with a custom collection decorator" do
134
134
  it "creates a custom collection decorator using itself for each item" do
135
- source = [Model.new]
135
+ object = [Model.new]
136
136
 
137
- ProductsDecorator.should_receive(:new).with(source, with: ProductDecorator)
138
- ProductDecorator.decorate_collection(source)
137
+ ProductsDecorator.should_receive(:new).with(object, with: ProductDecorator)
138
+ ProductDecorator.decorate_collection(object)
139
139
  end
140
140
 
141
141
  it "passes options to the collection decorator" do
@@ -157,74 +157,84 @@ module Draper
157
157
  describe ".decorates" do
158
158
  protect_class Decorator
159
159
 
160
- it "sets .source_class with a symbol" do
160
+ it "sets .object_class with a symbol" do
161
161
  Decorator.decorates :product
162
162
 
163
- expect(Decorator.source_class).to be Product
163
+ expect(Decorator.object_class).to be Product
164
164
  end
165
165
 
166
- it "sets .source_class with a string" do
166
+ it "sets .object_class with a string" do
167
167
  Decorator.decorates "product"
168
168
 
169
- expect(Decorator.source_class).to be Product
169
+ expect(Decorator.object_class).to be Product
170
170
  end
171
171
 
172
- it "sets .source_class with a class" do
172
+ it "sets .object_class with a class" do
173
173
  Decorator.decorates Product
174
174
 
175
- expect(Decorator.source_class).to be Product
175
+ expect(Decorator.object_class).to be Product
176
176
  end
177
177
  end
178
178
 
179
- describe ".source_class" do
179
+ describe ".object_class" do
180
180
  protect_class ProductDecorator
181
181
  protect_class Namespaced::ProductDecorator
182
182
 
183
183
  context "when not set by .decorates" do
184
184
  it "raises an UninferrableSourceError for a so-named 'Decorator'" do
185
- expect{Decorator.source_class}.to raise_error UninferrableSourceError
185
+ expect{Decorator.object_class}.to raise_error UninferrableSourceError
186
186
  end
187
187
 
188
188
  it "raises an UninferrableSourceError for anonymous decorators" do
189
- expect{Class.new(Decorator).source_class}.to raise_error UninferrableSourceError
189
+ expect{Class.new(Decorator).object_class}.to raise_error UninferrableSourceError
190
190
  end
191
191
 
192
192
  it "raises an UninferrableSourceError for a decorator without a model" do
193
- expect{OtherDecorator.source_class}.to raise_error UninferrableSourceError
193
+ expect{OtherDecorator.object_class}.to raise_error UninferrableSourceError
194
194
  end
195
195
 
196
196
  it "raises an UninferrableSourceError for other naming conventions" do
197
- expect{ProductPresenter.source_class}.to raise_error UninferrableSourceError
197
+ expect{ProductPresenter.object_class}.to raise_error UninferrableSourceError
198
198
  end
199
199
 
200
200
  it "infers the source for '<Model>Decorator'" do
201
- expect(ProductDecorator.source_class).to be Product
201
+ expect(ProductDecorator.object_class).to be Product
202
202
  end
203
203
 
204
204
  it "infers namespaced sources" do
205
- expect(Namespaced::ProductDecorator.source_class).to be Namespaced::Product
205
+ expect(Namespaced::ProductDecorator.object_class).to be Namespaced::Product
206
206
  end
207
207
 
208
208
  context "when an unrelated NameError is thrown" do
209
209
  it "re-raises that error" do
210
210
  String.any_instance.stub(:constantize).and_return{SomethingThatDoesntExist}
211
- expect{ProductDecorator.source_class}.to raise_error NameError, /SomethingThatDoesntExist/
211
+ expect{ProductDecorator.object_class}.to raise_error NameError, /SomethingThatDoesntExist/
212
212
  end
213
213
  end
214
214
  end
215
+
216
+ it "is aliased to .source_class" do
217
+ expect(ProductDecorator.source_class).to be Product
218
+ end
215
219
  end
216
220
 
217
- describe ".source_class?" do
218
- it "returns truthy when .source_class is set" do
219
- Decorator.stub(:source_class).and_return(Model)
221
+ describe ".object_class?" do
222
+ it "returns truthy when .object_class is set" do
223
+ Decorator.stub(:object_class).and_return(Model)
220
224
 
221
- expect(Decorator.source_class?).to be_true
225
+ expect(Decorator.object_class?).to be_true
226
+ end
227
+
228
+ it "returns false when .object_class is not inferrable" do
229
+ Decorator.stub(:object_class).and_raise(UninferrableSourceError.new(Decorator))
230
+
231
+ expect(Decorator.object_class?).to be_false
222
232
  end
223
233
 
224
- it "returns false when .source_class is not inferrable" do
225
- Decorator.stub(:source_class).and_raise(UninferrableSourceError.new(Decorator))
234
+ it "is aliased to .source_class?" do
235
+ Decorator.stub(:object_class).and_return(Model)
226
236
 
227
- expect(Decorator.source_class?).to be_false
237
+ expect(Decorator.source_class?).to be_true
228
238
  end
229
239
  end
230
240
 
@@ -319,14 +329,35 @@ module Draper
319
329
  end
320
330
  end
321
331
 
322
- describe "#source" do
332
+ describe "#object" do
323
333
  it "returns the wrapped object" do
324
- source = Model.new
325
- decorator = Decorator.new(source)
334
+ object = Model.new
335
+ decorator = Decorator.new(object)
336
+
337
+ expect(decorator.object).to be object
338
+ expect(decorator.model).to be object
339
+ expect(decorator.to_source).to be object
340
+ end
341
+
342
+ it "is aliased to #model" do
343
+ object = Model.new
344
+ decorator = Decorator.new(object)
326
345
 
327
- expect(decorator.source).to be source
328
- expect(decorator.model).to be source
329
- expect(decorator.to_source).to be source
346
+ expect(decorator.model).to be object
347
+ end
348
+
349
+ it "is aliased to #source" do
350
+ object = Model.new
351
+ decorator = Decorator.new(object)
352
+
353
+ expect(decorator.source).to be object
354
+ end
355
+
356
+ it "is aliased to #to_source" do
357
+ object = Model.new
358
+ decorator = Decorator.new(object)
359
+
360
+ expect(decorator.to_source).to be object
330
361
  end
331
362
  end
332
363
 
@@ -339,7 +370,7 @@ module Draper
339
370
  end
340
371
 
341
372
  describe "#to_param" do
342
- it "delegates to the source" do
373
+ it "delegates to the object" do
343
374
  decorator = Decorator.new(double(to_param: :delegated))
344
375
 
345
376
  expect(decorator.to_param).to be :delegated
@@ -347,15 +378,23 @@ module Draper
347
378
  end
348
379
 
349
380
  describe "#present?" do
350
- it "delegates to the source" do
381
+ it "delegates to the object" do
351
382
  decorator = Decorator.new(double(present?: :delegated))
352
383
 
353
384
  expect(decorator.present?).to be :delegated
354
385
  end
355
386
  end
356
387
 
388
+ describe "#blank?" do
389
+ it "delegates to the object" do
390
+ decorator = Decorator.new(double(blank?: :delegated))
391
+
392
+ expect(decorator.blank?).to be :delegated
393
+ end
394
+ end
395
+
357
396
  describe "#to_partial_path" do
358
- it "delegates to the source" do
397
+ it "delegates to the object" do
359
398
  decorator = Decorator.new(double(to_partial_path: :delegated))
360
399
 
361
400
  expect(decorator.to_partial_path).to be :delegated
@@ -363,7 +402,7 @@ module Draper
363
402
  end
364
403
 
365
404
  describe "#attributes" do
366
- it "returns only the source's attributes that are implemented by the decorator" do
405
+ it "returns only the object's attributes that are implemented by the decorator" do
367
406
  decorator = Decorator.new(double(attributes: {foo: "bar", baz: "qux"}))
368
407
  decorator.stub(:foo)
369
408
 
@@ -373,42 +412,42 @@ module Draper
373
412
 
374
413
  describe ".model_name" do
375
414
  it "delegates to the source class" do
376
- Decorator.stub source_class: double(model_name: :delegated)
415
+ Decorator.stub object_class: double(model_name: :delegated)
377
416
 
378
417
  expect(Decorator.model_name).to be :delegated
379
418
  end
380
419
  end
381
420
 
382
421
  describe "#==" do
383
- it "works for a source that does not include Decoratable" do
384
- source = Object.new
385
- decorator = Decorator.new(source)
422
+ it "works for a object that does not include Decoratable" do
423
+ object = Object.new
424
+ decorator = Decorator.new(object)
386
425
 
387
- expect(decorator).to eq Decorator.new(source)
426
+ expect(decorator).to eq Decorator.new(object)
388
427
  end
389
428
 
390
- it "works for a multiply-decorated source that does not include Decoratable" do
391
- source = Object.new
392
- decorator = Decorator.new(source)
429
+ it "works for a multiply-decorated object that does not include Decoratable" do
430
+ object = Object.new
431
+ decorator = Decorator.new(object)
393
432
 
394
- expect(decorator).to eq ProductDecorator.new(Decorator.new(source))
433
+ expect(decorator).to eq ProductDecorator.new(Decorator.new(object))
395
434
  end
396
435
 
397
- it "is true when source #== is true" do
398
- source = Model.new
399
- decorator = Decorator.new(source)
400
- other = double(source: Model.new)
436
+ it "is true when object #== is true" do
437
+ object = Model.new
438
+ decorator = Decorator.new(object)
439
+ other = double(object: Model.new)
401
440
 
402
- source.should_receive(:==).with(other).and_return(true)
441
+ object.should_receive(:==).with(other).and_return(true)
403
442
  expect(decorator == other).to be_true
404
443
  end
405
444
 
406
- it "is false when source #== is false" do
407
- source = Model.new
408
- decorator = Decorator.new(source)
409
- other = double(source: Model.new)
445
+ it "is false when object #== is false" do
446
+ object = Model.new
447
+ decorator = Decorator.new(object)
448
+ other = double(object: Model.new)
410
449
 
411
- source.should_receive(:==).with(other).and_return(false)
450
+ object.should_receive(:==).with(other).and_return(false)
412
451
  expect(decorator == other).to be_false
413
452
  end
414
453
 
@@ -433,8 +472,8 @@ module Draper
433
472
  describe ".delegate" do
434
473
  protect_class Decorator
435
474
 
436
- it "defaults the :to option to :source" do
437
- Object.should_receive(:delegate).with(:foo, :bar, to: :source)
475
+ it "defaults the :to option to :object" do
476
+ Object.should_receive(:delegate).with(:foo, :bar, to: :object)
438
477
  Decorator.delegate :foo, :bar
439
478
  end
440
479
 
@@ -450,7 +489,7 @@ module Draper
450
489
  before { Decorator.delegate_all }
451
490
 
452
491
  describe "#method_missing" do
453
- it "delegates missing methods that exist on the source" do
492
+ it "delegates missing methods that exist on the object" do
454
493
  decorator = Decorator.new(double(hello_world: :delegated))
455
494
 
456
495
  expect(decorator.hello_world).to be :delegated
@@ -465,9 +504,9 @@ module Draper
465
504
  end
466
505
 
467
506
  it "passes blocks to delegated methods" do
468
- source = Model.new
469
- source.stub(:hello_world).and_return{|*args, &block| block.call}
470
- decorator = Decorator.new(source)
507
+ object = Model.new
508
+ object.stub(:hello_world).and_return{|*args, &block| block.call}
509
+ decorator = Decorator.new(object)
471
510
 
472
511
  expect(decorator.hello_world{:yielded}).to be :yielded
473
512
  end
@@ -479,21 +518,21 @@ module Draper
479
518
  end
480
519
 
481
520
  it "delegates already-delegated methods" do
482
- source = Class.new{ delegate :bar, to: :foo }.new
483
- source.stub foo: double(bar: :delegated)
484
- decorator = Decorator.new(source)
521
+ object = Class.new{ delegate :bar, to: :foo }.new
522
+ object.stub foo: double(bar: :delegated)
523
+ decorator = Decorator.new(object)
485
524
 
486
525
  expect(decorator.bar).to be :delegated
487
526
  end
488
527
 
489
528
  it "does not delegate private methods" do
490
- source = Class.new{ private; def hello_world; end }.new
491
- decorator = Decorator.new(source)
529
+ object = Class.new{ private; def hello_world; end }.new
530
+ decorator = Decorator.new(object)
492
531
 
493
532
  expect{decorator.hello_world}.to raise_error NoMethodError
494
533
  end
495
534
 
496
- it "does not delegate methods that do not exist on the source" do
535
+ it "does not delegate methods that do not exist on the object" do
497
536
  decorator = Decorator.new(Model.new)
498
537
 
499
538
  expect(decorator.methods).not_to include :hello_world
@@ -511,15 +550,15 @@ module Draper
511
550
 
512
551
  context "with a source class" do
513
552
  it "delegates methods that exist on the source class" do
514
- source_class = Class.new
515
- source_class.stub hello_world: :delegated
516
- Decorator.stub source_class: source_class
553
+ object_class = Class.new
554
+ object_class.stub hello_world: :delegated
555
+ Decorator.stub object_class: object_class
517
556
 
518
557
  expect(Decorator.hello_world).to be :delegated
519
558
  end
520
559
 
521
560
  it "does not delegate methods that do not exist on the source class" do
522
- Decorator.stub source_class: Class.new
561
+ Decorator.stub object_class: Class.new
523
562
 
524
563
  expect{Decorator.hello_world}.to raise_error NoMethodError
525
564
  end
@@ -534,7 +573,7 @@ module Draper
534
573
  expect(decorator).to respond_to :hello_world
535
574
  end
536
575
 
537
- it "returns true for the source's methods" do
576
+ it "returns true for the object's methods" do
538
577
  decorator = Decorator.new(double(hello_world: :delegated))
539
578
 
540
579
  expect(decorator).to respond_to :hello_world
@@ -548,9 +587,9 @@ module Draper
548
587
  expect(decorator.respond_to?(:hello_world, true)).to be_true
549
588
  end
550
589
 
551
- it "returns false for the source's private methods" do
552
- source = Class.new{private; def hello_world; end}.new
553
- decorator = Decorator.new(source)
590
+ it "returns false for the object's private methods" do
591
+ object = Class.new{private; def hello_world; end}.new
592
+ decorator = Decorator.new(object)
554
593
 
555
594
  expect(decorator.respond_to?(:hello_world, true)).to be_false
556
595
  end
@@ -573,13 +612,13 @@ module Draper
573
612
  context "with a source class" do
574
613
  it "returns true for its own class methods" do
575
614
  Decorator.class_eval{def self.hello_world; end}
576
- Decorator.stub source_class: Class.new
615
+ Decorator.stub object_class: Class.new
577
616
 
578
617
  expect(Decorator).to respond_to :hello_world
579
618
  end
580
619
 
581
620
  it "returns true for the source's class methods" do
582
- Decorator.stub source_class: double(hello_world: :delegated)
621
+ Decorator.stub object_class: double(hello_world: :delegated)
583
622
 
584
623
  expect(Decorator).to respond_to :hello_world
585
624
  end
@@ -588,8 +627,8 @@ module Draper
588
627
 
589
628
  describe "#respond_to_missing?" do
590
629
  it "allows #method to be called on delegated methods" do
591
- source = Class.new{def hello_world; end}.new
592
- decorator = Decorator.new(source)
630
+ object = Class.new{def hello_world; end}.new
631
+ decorator = Decorator.new(object)
593
632
 
594
633
  expect { decorator.method(:hello_world) }.not_to raise_error NameError
595
634
  expect(decorator.method(:hello_world)).not_to be_nil
@@ -598,7 +637,7 @@ module Draper
598
637
 
599
638
  describe ".respond_to_missing?" do
600
639
  it "allows .method to be called on delegated class methods" do
601
- Decorator.stub source_class: double(hello_world: :delegated)
640
+ Decorator.stub object_class: double(hello_world: :delegated)
602
641
 
603
642
  expect { Decorator.method(:hello_world) }.not_to raise_error NameError
604
643
  expect(Decorator.method(:hello_world)).not_to be_nil