grape-entity-matchers 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e4a77ad8de5fcd52e5779362cb357986aa797ae5
4
- data.tar.gz: b215fa9e8c378c4693f219bbdeab5ecff6451ebe
3
+ metadata.gz: edb2095f5507a42699c1f5562b058a2cead368f4
4
+ data.tar.gz: 9a719010ef85bfcc0ab589c35ca29c8b6f8bf245
5
5
  SHA512:
6
- metadata.gz: 494d033ea301b521801be9e73c426b98a6d73f7f875a6256347c0568e5c4c29beddfad12f8815d41d79ce1c042fcff0442d2c5b4670b42178b2ba8eedabcf96f
7
- data.tar.gz: bde091cdeaf87af6b12b4ab69801111472bba8bb864d5f7e5bb3a35cc7d4bff28b4a1a727369f7c48917817bfd1ff2162ed3a5997321af802ee8cfae78cf3627
6
+ metadata.gz: 6ec81ccd12efb64cc01f36c6e97930c53f2df3cc7673846b4036482dd2a91f2215886a5d8bc8a55d166c1d0f37f39c720a3b5c697c0729137850eaefcf167840
7
+ data.tar.gz: 2cce47ef4587a766e58f9106b8e1f31c370abab053fd2b7ae64df9dbd7956fe09a68a6a2b092130ea306eba8335cd28bfe929ae5b52b2529932530bee77d4a40
@@ -1,8 +1,6 @@
1
1
  rvm:
2
- - 1.8.7
3
- - 1.9.2
2
+ - 2.1.0
3
+ - 2.0.0
4
4
  - 1.9.3
5
5
  - jruby
6
6
  - rbx
7
- - ree
8
-
@@ -3,6 +3,10 @@ Next Release
3
3
  * move support from rspec 2.x to rspec 3.x
4
4
  * add support for minitest
5
5
 
6
+ 0.4.1 (02/22/2014)
7
+ ============
8
+ * fix error when an entity contains itself nested by nil-ing out the nested version.
9
+
6
10
  0.4.0 (02/22/2014)
7
11
  ============
8
12
  * Support grape-entity 0.4.0.
@@ -32,7 +32,9 @@ module GrapeEntityMatchers
32
32
  def using(other_entity)
33
33
  @other_entity = other_entity
34
34
  @represented_attribute = double("RepresetedAttribute")
35
- @other_entity.exposures.keys.each {|key| allow(@represented_attribute ).to receive(key).and_return(:value)}
35
+ @other_entity.exposures.keys.each do |key|
36
+ allow(@represented_attribute ).to receive(key).and_return( @other_entity.exposures[key].nil? ? :value : nil)
37
+ end
36
38
  self
37
39
  end
38
40
 
@@ -126,7 +128,11 @@ module GrapeEntityMatchers
126
128
  def check_value
127
129
  if @other_entity
128
130
  other_representation = @other_entity.represent(@represented_attribute)
129
- other_representation.exposures.keys.each {|key| allow(other_representation).to receive(key).and_return(:value)}
131
+
132
+ other_representation.exposures.keys.each do |key|
133
+ allow(other_representation).to receive(key).and_return( other_representation.exposures[key].nil? ? :value : nil)
134
+ end
135
+
130
136
  @serialized_hash[@actual_representation || @expected_representable] == other_representation.serializable_hash
131
137
  else
132
138
  @serialized_hash[@actual_representation || @expected_representable] == :value
@@ -1,3 +1,3 @@
1
1
  module GrapeEntityMatchers
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'
3
3
  end
@@ -10,7 +10,7 @@ describe GrapeEntityMatchers do
10
10
  include Grape::Entity::DSL
11
11
  entity :name, :age do
12
12
  expose :date_of_birth, :as => :birthday
13
- expose :cat, :as => :cat, :using => PetEntity
13
+ expose :cat, :as => :feline, :using => PetEntity
14
14
  expose :dog, :using => PetEntity
15
15
  expose :secret, :if => lambda{ |person, options| person.authorized? }
16
16
  expose :super_dooper_secret, :as => :top_secret, :if => lambda{ |person, options| person.authorized? }
@@ -20,6 +20,11 @@ describe GrapeEntityMatchers do
20
20
  root 'vets', 'vet'
21
21
  expose :name
22
22
  end
23
+ class ItemEntity < Grape::Entity
24
+ expose :name
25
+ expose :name, as: :title
26
+ expose :sub_items, as: :children, using: ItemEntity
27
+ end
23
28
  nil
24
29
  end
25
30
 
@@ -49,7 +54,7 @@ describe GrapeEntityMatchers do
49
54
  it { should_not represent(:super_dooper_secret).when( :authorized? => true ) }
50
55
 
51
56
  it { should represent(:dog).using(PetEntity) }
52
- it { should represent(:cat).as(:cat).using(PetEntity) }
57
+ it { should represent(:cat).as(:feline).using(PetEntity) }
53
58
  it { should_not represent(:cat).using(PetEntity) }
54
59
 
55
60
  end
@@ -58,4 +63,10 @@ describe GrapeEntityMatchers do
58
63
  subject(:entity) { Vet }
59
64
  it { should represent(:name).with_root('vet') }
60
65
  end
66
+
67
+ context 'matchers with with a tree structure' do
68
+ subject(:entity) { ItemEntity }
69
+ it { should represent(:name).as(:title) }
70
+ it { should represent(:sub_items).as(:children).using(ItemEntity) }
71
+ end
61
72
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-entity-matchers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Madsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-23 00:00:00.000000000 Z
11
+ date: 2014-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grape-entity