hal-client 3.5.1 → 3.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/lib/hal_client/representation.rb +19 -1
- data/lib/hal_client/version.rb +1 -1
- data/spec/hal_client/representation_spec.rb +41 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81cff13c5addef810f60d7f582893755f5c5002c
|
4
|
+
data.tar.gz: 50afe68ae72932b61422c8f0c784cbacc0058466
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd8b9912c0efaf36e53d58a0f36796df851d30ffd9ea3f78741d0c3c9cd20692f87f19163e21bbdd968cadb9bbb73a8a2ce1d0266ecb11aff990446d476afb77
|
7
|
+
data.tar.gz: d930ba6fc1f828b0120e296338c9e8386495531617d9a271212471c870d41470fb9f444ea14b6fdcf983b31e1bd9c15bf2ef601d96762ee08e009a592eee09d3
|
data/.travis.yml
CHANGED
@@ -238,6 +238,25 @@ class HalClient
|
|
238
238
|
end
|
239
239
|
alias_method :to_hal, :to_json
|
240
240
|
|
241
|
+
def hash
|
242
|
+
if href
|
243
|
+
href.hash
|
244
|
+
else
|
245
|
+
@raw.hash
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
def ==(other)
|
250
|
+
if href && other.respond_to?(:href)
|
251
|
+
href == other.href
|
252
|
+
elsif other.respond_to?(:raw)
|
253
|
+
@raw == other.raw
|
254
|
+
else
|
255
|
+
false
|
256
|
+
end
|
257
|
+
end
|
258
|
+
alias :eql? :==
|
259
|
+
|
241
260
|
# Internal: Returns parsed json document
|
242
261
|
def raw
|
243
262
|
if @raw.nil? && @href
|
@@ -328,6 +347,5 @@ end
|
|
328
347
|
end
|
329
348
|
|
330
349
|
def_delegators :links, :namespaces
|
331
|
-
|
332
350
|
end
|
333
351
|
end
|
data/lib/hal_client/version.rb
CHANGED
@@ -112,6 +112,47 @@ HAL
|
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
|
+
context "equality and hash" do
|
116
|
+
let(:repr_same_href) { described_class.new(hal_client: a_client,
|
117
|
+
parsed_json: MultiJson.load(<<-HAL)) }
|
118
|
+
{ "_links": { "self": { "href": "http://example.com/foo" } } }
|
119
|
+
HAL
|
120
|
+
|
121
|
+
let(:repr_diff_href) { described_class.new(hal_client: a_client,
|
122
|
+
parsed_json: MultiJson.load(<<-HAL)) }
|
123
|
+
{ "_links": { "self": { "href": "http://DIFFERENT" } } }
|
124
|
+
HAL
|
125
|
+
let(:repr_no_href) { described_class.new(hal_client: a_client,
|
126
|
+
parsed_json: MultiJson.load(<<-HAL)) }
|
127
|
+
{ }
|
128
|
+
HAL
|
129
|
+
|
130
|
+
describe "#==" do
|
131
|
+
specify { expect(repr == repr_same_href).to eq true }
|
132
|
+
specify { expect(repr == repr_diff_href).to eq false }
|
133
|
+
specify { expect(repr == repr_no_href).to eq false }
|
134
|
+
specify { expect(repr_no_href == repr).to eq false }
|
135
|
+
specify { expect(repr_no_href == repr_no_href).to eq true }
|
136
|
+
specify { expect(repr == Object.new).to eq false }
|
137
|
+
end
|
138
|
+
|
139
|
+
describe ".eql?" do
|
140
|
+
specify { expect(repr.eql? repr_same_href).to eq true }
|
141
|
+
specify { expect(repr.eql? repr_diff_href).to eq false }
|
142
|
+
specify { expect(repr.eql? repr_no_href).to eq false }
|
143
|
+
specify { expect(repr_no_href.eql? repr).to eq false }
|
144
|
+
specify { expect(repr_no_href.eql? repr_no_href).to eq true }
|
145
|
+
specify { expect(repr.eql? Object.new).to eq false }
|
146
|
+
end
|
147
|
+
|
148
|
+
describe "hash" do
|
149
|
+
specify{ expect(repr.hash).to eq repr.href.hash }
|
150
|
+
specify{ expect(repr_no_href.hash).to eq repr_no_href.raw.hash }
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
|
155
|
+
|
115
156
|
specify { expect(repr.property "prop1").to eq 1 }
|
116
157
|
specify { expect{repr.property "nonexistent-prop"}.to raise_exception KeyError }
|
117
158
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hal-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|