rest_my_case 1.10.7 → 1.10.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YmJmYmE1OGE0MGY2ZjA3MjMwOTE2ODQxYTIxYWZmM2E1M2IyZDkxOA==
4
+ MDcxNjdjZWE5MzY5NTJjMmQ2YTVmMzM3ODc5Y2Y5MjNkNjcyZjVkMQ==
5
5
  data.tar.gz: !binary |-
6
- Zjk0NGQwMGRiNjRhODFmMDQ3MmM5N2RiODRlMThmMDBiYjljOGI1NA==
6
+ NjUyMjQ0OTM5NGI2Yjg0ZTkyZjBlOTUwNGE4YjQyNzY1N2U1MGJkYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjNkYTcxMGJhMzcxZDZlNjMwNDE5ZGQxMjQxMWJmMjNiODhiZGRlMjFiMzNm
10
- MTdiODRkOTNjOTdhMTgyMmZmY2VlZTRjNTQ3ZGQyMzc2ZDY1ZjY0N2VjMDM0
11
- NzNmMWMzMjQ0MzQ5NTAwYmZjMDg2MmVlOGE3ZmRjZGFiNWZjMWE=
9
+ MmE1MTA3NDkwYjQzMjQxYzk4MDZiMjY5Y2ZhNTI3ZjU1NGQxMmQwZmUwZDAx
10
+ ODBiMWYxNDUwNGE5M2JmOTc0MGVmZDk5OWZkYTcwNWZkYjQ1MGY5NDVjMDBh
11
+ ZDIzYjk4NDBlMWQ4MTg3NTI5OTg0ZjY4NzA3NDI4OTUzN2E2MTg=
12
12
  data.tar.gz: !binary |-
13
- ZDViMmUzY2MyNzBiMTBkMjg5Y2Q5OTBhZGE0ZmExNmJjY2ZiYWY0ZDdhYzU4
14
- OTFiM2I3OTk3ZDQ4MDI2MTE4ODU1OTEyMWEzMjEzMzU0OTk3ZjNkYjVhNDFj
15
- NjAwOTZjYjk3NDRiMGM2M2YwMTE5NjE1ODViYmU3MjJlNDA5MmI=
13
+ OWQ3NWViNGU1MGRmMmZlODU5NGIyZjdhYmZlZjBlYWNhN2IyZDBlNjllZDAx
14
+ NjNjODM0MzY4YjIyZmVhZjkyMjhkZTc5NGFkZThlNDU1ZTEyODY4MjBlNjlh
15
+ MGI1NzhlZGFiMDFjYWVjYWEyNjFlMWMyNGYzMjkxNzQ2Y2ZmYWE=
@@ -75,13 +75,15 @@ module RestMyCase
75
75
  def target
76
76
  return nil if target_options[:name].nil?
77
77
 
78
+ target_content = get_target(target_options[:name])
79
+
78
80
  if parent_target
79
81
  extend_errors_if_necessary(parent_target)
80
82
 
81
- parent_target.send(target_options[:name])
82
- else
83
- get_target(target_options[:name])
83
+ target_content ||= parent_target.send(target_options[:name])
84
84
  end
85
+
86
+ target_content
85
87
  end
86
88
 
87
89
  def perform
@@ -1,5 +1,5 @@
1
1
  module RestMyCase
2
2
 
3
- VERSION = '1.10.7'
3
+ VERSION = '1.10.8'
4
4
 
5
5
  end
@@ -226,7 +226,7 @@ describe RestMyCase::Validator do
226
226
  { title: 'second comment' }
227
227
  ])
228
228
 
229
- @context = NestedValidation.perform(post: @post_with_comments)
229
+ @context = NestedValidation::Base.perform(post: @post_with_comments)
230
230
  end
231
231
 
232
232
  it "@context.ok? should be true" do
@@ -251,7 +251,7 @@ describe RestMyCase::Validator do
251
251
  {}
252
252
  ])
253
253
 
254
- @context = NestedValidation.perform(post: @post_with_comments)
254
+ @context = NestedValidation::Base.perform(post: @post_with_comments)
255
255
  end
256
256
 
257
257
  it "@context.ok? should be false" do
@@ -273,6 +273,61 @@ describe RestMyCase::Validator do
273
273
  end
274
274
  end
275
275
 
276
+ context "Validator has a method with the same name has the target" do
277
+ before do
278
+ @post_with_comments = RubyPostWithComments.new([
279
+ { title: 'first comment' },
280
+ {}
281
+ ])
282
+
283
+ @context = NestedValidation::ValidatorSameMethod.perform(post: @post_with_comments)
284
+ end
285
+
286
+ it "@context.ok? should be true" do
287
+ expect(@context.ok?).to be true
288
+ end
289
+
290
+ it "@post_with_comments should not contain errors" do
291
+ expect(@post_with_comments.errors.count).to be 0
292
+ end
293
+
294
+ it "@context._comments should not contain errors" do
295
+ @context._comments.each do |comment|
296
+ expect(comment.errors.count).to be 0
297
+ end
298
+ end
299
+ end
300
+
301
+ context "Context has a method with the same name has the target" do
302
+ before do
303
+ @post_with_comments = RubyPostWithComments.new([
304
+ { title: 'first comment' },
305
+ {}
306
+ ])
307
+
308
+ @context = NestedValidation::Base.perform(
309
+ post: @post_with_comments,
310
+ comments: [
311
+ RubyPostWithComments::RubyComment.new({ title: 'first comment' }),
312
+ RubyPostWithComments::RubyComment.new({ title: 'second comment' })
313
+ ])
314
+ end
315
+
316
+ it "@context.ok? should be true" do
317
+ expect(@context.ok?).to be true
318
+ end
319
+
320
+ it "@post_with_comments should not contain errors" do
321
+ expect(@post_with_comments.errors.count).to be 0
322
+ end
323
+
324
+ it "@context.comments should not contain errors" do
325
+ @context.comments.each do |comment|
326
+ expect(comment.errors.count).to be 0
327
+ end
328
+ end
329
+ end
330
+
276
331
  end
277
332
 
278
333
  end
@@ -1,7 +1,30 @@
1
- class NestedValidation < RestMyCase::Validator
1
+ module NestedValidation
2
2
 
3
- target :comments, in: :post
3
+ class Base < RestMyCase::Validator
4
4
 
5
- validates_presence_of :title
5
+ target :comments, in: :post
6
+
7
+ validates_presence_of :title
8
+
9
+ end
10
+
11
+ class ValidatorSameMethod < RestMyCase::Validator
12
+
13
+ target :comments, in: :post
14
+
15
+ validates_presence_of :title
16
+
17
+ def setup
18
+ context._comments = comments
19
+ end
20
+
21
+ def comments
22
+ @comments ||= [
23
+ RubyPostWithComments::RubyComment.new({ title: 'first comment' }),
24
+ RubyPostWithComments::RubyComment.new({ title: 'second comment' })
25
+ ]
26
+ end
27
+
28
+ end
6
29
 
7
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest_my_case
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.7
4
+ version: 1.10.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - goncalvesjoao
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-28 00:00:00.000000000 Z
11
+ date: 2015-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry