roar-extensions 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/roar_extensions/hypermedia_extensions.rb +7 -0
- data/lib/roar_extensions/link_presenter.rb +2 -2
- data/lib/roar_extensions/version.rb +1 -1
- data/lib/roar_extensions.rb +2 -0
- data/spec/link_presenter_spec.rb +5 -5
- data/spec/presenter_spec.rb +3 -3
- data/spec/resource_links_spec.rb +2 -2
- data/spec/roar/representer/feature/hypermedia_spec.rb +8 -5
- metadata +3 -2
data/lib/roar_extensions.rb
CHANGED
@@ -17,6 +17,7 @@ end
|
|
17
17
|
|
18
18
|
require 'active_support'
|
19
19
|
require 'active_support/core_ext/module'
|
20
|
+
require 'active_support/core_ext/hash/keys'
|
20
21
|
|
21
22
|
require 'roar_extensions/helpers/embedded_parameter_parsing'
|
22
23
|
require 'roar_extensions/json_hal_extensions'
|
@@ -28,3 +29,4 @@ require 'roar_extensions/link_presenter'
|
|
28
29
|
require 'roar_extensions/money_presenter'
|
29
30
|
require 'roar_extensions/paginated_collection_presenter'
|
30
31
|
require 'roar_extensions/resource_links'
|
32
|
+
require 'roar_extensions/hypermedia_extensions'
|
data/spec/link_presenter_spec.rb
CHANGED
@@ -19,7 +19,7 @@ module RoarExtensions
|
|
19
19
|
|
20
20
|
context "no title" do
|
21
21
|
its(:as_json) do
|
22
|
-
should == { 'search_engine' => {
|
22
|
+
should == { 'search_engine' => {'href' => 'http://google.com'} }
|
23
23
|
end
|
24
24
|
|
25
25
|
it "aliases to_hash to as_json" do
|
@@ -29,13 +29,13 @@ module RoarExtensions
|
|
29
29
|
|
30
30
|
context "title given" do
|
31
31
|
subject { LinkPresenter.new('search_engine',
|
32
|
-
|
33
|
-
|
32
|
+
'http://google.com',
|
33
|
+
'Cool Search') }
|
34
34
|
its(:as_json) do
|
35
35
|
should == {
|
36
36
|
'search_engine' => {
|
37
|
-
|
38
|
-
|
37
|
+
'href' => 'http://google.com',
|
38
|
+
'title' => 'Cool Search'
|
39
39
|
}
|
40
40
|
}
|
41
41
|
end
|
data/spec/presenter_spec.rb
CHANGED
@@ -121,9 +121,9 @@ module RoarExtensions
|
|
121
121
|
|
122
122
|
it "has api _links" do
|
123
123
|
subject['_links'].should == {
|
124
|
-
'self' => {
|
125
|
-
'related_products' => {
|
126
|
-
'category' => {
|
124
|
+
'self' => { "href" => "/v1/products/9001" },
|
125
|
+
'related_products' => { "href" => "/v1/products/9001/related" },
|
126
|
+
'category' => { "href" => '/v1/categories/800'}
|
127
127
|
}
|
128
128
|
end
|
129
129
|
|
data/spec/resource_links_spec.rb
CHANGED
@@ -33,8 +33,8 @@ module RoarExtensions
|
|
33
33
|
it "turns a hash with keys as rels into proper link representations" do
|
34
34
|
subject.test_resource_link_json('self' => '/foo', 'next' => '/bar').
|
35
35
|
should == {
|
36
|
-
'self' => {
|
37
|
-
'next' => {
|
36
|
+
'self' => { 'href' => '/foo' },
|
37
|
+
'next' => { 'href' => '/bar' }
|
38
38
|
}
|
39
39
|
end
|
40
40
|
end
|
@@ -8,17 +8,20 @@ describe Roar::Representer::JSON::HAL do
|
|
8
8
|
Module.new do
|
9
9
|
include Roar::Representer::JSON
|
10
10
|
include Roar::Representer::Feature::Hypermedia
|
11
|
-
end
|
12
|
-
end
|
13
11
|
|
14
|
-
it "accepts strings for rel" do
|
15
|
-
mod.class_eval do
|
16
12
|
link :rel => 'self', :title => "Hey, @myabc" do
|
17
13
|
"http://self"
|
18
14
|
end
|
19
15
|
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it "accepts strings for rel" do
|
19
|
+
Object.new.extend(mod).to_hash['links'][0]['rel'].should == 'self'
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
+
it "returns string keys" do
|
23
|
+
Object.new.extend(mod).to_hash['links'][0].keys.sort.
|
24
|
+
should == ['href', 'rel', 'title']
|
22
25
|
end
|
23
26
|
end
|
24
27
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roar-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-09-
|
13
|
+
date: 2012-09-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: roar
|
@@ -158,6 +158,7 @@ files:
|
|
158
158
|
- lib/roar_extensions.rb
|
159
159
|
- lib/roar_extensions/destroyed_record_presenter.rb
|
160
160
|
- lib/roar_extensions/helpers/embedded_parameter_parsing.rb
|
161
|
+
- lib/roar_extensions/hypermedia_extensions.rb
|
161
162
|
- lib/roar_extensions/json_hal_extensions.rb
|
162
163
|
- lib/roar_extensions/link_presenter.rb
|
163
164
|
- lib/roar_extensions/money_presenter.rb
|