grape-entity-matchers 0.4.0 → 0.4.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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edb2095f5507a42699c1f5562b058a2cead368f4
|
4
|
+
data.tar.gz: 9a719010ef85bfcc0ab589c35ca29c8b6f8bf245
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ec81ccd12efb64cc01f36c6e97930c53f2df3cc7673846b4036482dd2a91f2215886a5d8bc8a55d166c1d0f37f39c720a3b5c697c0729137850eaefcf167840
|
7
|
+
data.tar.gz: 2cce47ef4587a766e58f9106b8e1f31c370abab053fd2b7ae64df9dbd7956fe09a68a6a2b092130ea306eba8335cd28bfe929ae5b52b2529932530bee77d4a40
|
data/.travis.yml
CHANGED
data/CHANGELOG.markdown
CHANGED
@@ -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
|
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
|
-
|
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
|
@@ -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 => :
|
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(:
|
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.
|
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-
|
11
|
+
date: 2014-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: grape-entity
|