restfolia-uritemplate 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/spec/fixtures/index.json +23 -0
- data/spec/lib/restfolia/entry_point_spec.rb +28 -0
- data/spec/lib/restfolia_spec.rb +14 -0
- data/spec/spec_helper.rb +22 -0
- metadata +148 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
{
|
2
|
+
"value": 10,
|
3
|
+
"name": "Test",
|
4
|
+
"query": null,
|
5
|
+
"tested": false,
|
6
|
+
"links": [
|
7
|
+
{
|
8
|
+
"href": "http://local.tester.anti.bug/{term:1}/{term}",
|
9
|
+
"rel": "search",
|
10
|
+
"type": "application/json"
|
11
|
+
},
|
12
|
+
{
|
13
|
+
"href": "http://local.tester.anti.bug/foo{?query,number}",
|
14
|
+
"rel": "another_search",
|
15
|
+
"type": "application/json"
|
16
|
+
},
|
17
|
+
{
|
18
|
+
"href": "http://local.tester.anti.bug/resource/index",
|
19
|
+
"rel": "self",
|
20
|
+
"type": "application/json"
|
21
|
+
}
|
22
|
+
]
|
23
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "spec/spec_helper"
|
2
|
+
|
3
|
+
describe Restfolia::EntryPoint do
|
4
|
+
|
5
|
+
context "should apply expansion with valid expression" do
|
6
|
+
subject { Restfolia::EntryPoint.new("http://example.com/~{username}/", "search").expand(:username => "bug") }
|
7
|
+
|
8
|
+
its(:class) { should == Restfolia::EntryPoint }
|
9
|
+
its(:url) { should == "http://example.com/~bug/" }
|
10
|
+
its(:rel) { should be_nil }
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should raise exception when url is empty" do
|
14
|
+
ep = Restfolia::EntryPoint.new("", "search")
|
15
|
+
lambda { ep.expand(:teste => false) }.should raise_error ArgumentError, Restfolia::Uritemplate::ExpansionSupport::INVALID_URL
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should raise exception when url is invalid" do
|
19
|
+
ep = Restfolia::EntryPoint.new("@@bla", "search")
|
20
|
+
lambda { ep.expand(:teste => false) }.should raise_error ArgumentError, Restfolia::Uritemplate::ExpansionSupport::INVALID_URL
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should raise exception when params is not a valid hash" do
|
24
|
+
ep = Restfolia::EntryPoint.new("http://example.com/~{username}/", "search")
|
25
|
+
lambda { ep.expand(:what) }.should raise_error ArgumentError, Restfolia::Uritemplate::ExpansionSupport::INVALID_PARAMETER
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
|
3
|
+
describe Restfolia do
|
4
|
+
|
5
|
+
let(:url) { "http://local.tester.anti.bug/resource/index" }
|
6
|
+
before { register_uri(:get, url, :body => fixture('index.json')) }
|
7
|
+
|
8
|
+
subject { Restfolia.at(url).get.links('search').expand(:term => "dog") }
|
9
|
+
|
10
|
+
its(:class) { should == Restfolia::EntryPoint }
|
11
|
+
its(:url) { should == "http://local.tester.anti.bug/d/dog" }
|
12
|
+
its(:rel) { should be_nil }
|
13
|
+
|
14
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'restfolia_uritemplate'
|
5
|
+
require 'fakeweb'
|
6
|
+
|
7
|
+
# Requires supporting files with custom matchers and macros, etc,
|
8
|
+
# in ./support/ and its subdirectories.
|
9
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
FakeWeb.allow_net_connect = false
|
13
|
+
|
14
|
+
def fixture(name)
|
15
|
+
File.readlines("#{File.dirname(__FILE__)}/fixtures/#{name}").to_s
|
16
|
+
end
|
17
|
+
|
18
|
+
def register_uri(method, uri, options = {})
|
19
|
+
options.merge!(:content_type => "application/json; charset=utf-8") if options[:content_type].nil?
|
20
|
+
FakeWeb.register_uri(method, uri, options)
|
21
|
+
end
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: restfolia-uritemplate
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Nadilson
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-06-12 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
prerelease: false
|
22
|
+
type: :runtime
|
23
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 21
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 0
|
32
|
+
- 1
|
33
|
+
version: 1.0.1
|
34
|
+
requirement: *id001
|
35
|
+
name: restfolia
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
prerelease: false
|
38
|
+
type: :runtime
|
39
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 19
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
- 3
|
48
|
+
- 0
|
49
|
+
version: 0.3.0
|
50
|
+
requirement: *id002
|
51
|
+
name: uri_template
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
prerelease: false
|
54
|
+
type: :development
|
55
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - "="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 27
|
61
|
+
segments:
|
62
|
+
- 1
|
63
|
+
- 3
|
64
|
+
- 0
|
65
|
+
version: 1.3.0
|
66
|
+
requirement: *id003
|
67
|
+
name: fakeweb
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
prerelease: false
|
70
|
+
type: :development
|
71
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
hash: 3
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
version: "0"
|
80
|
+
requirement: *id004
|
81
|
+
name: rake
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
prerelease: false
|
84
|
+
type: :development
|
85
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ~>
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
hash: 47
|
91
|
+
segments:
|
92
|
+
- 2
|
93
|
+
- 8
|
94
|
+
- 0
|
95
|
+
version: 2.8.0
|
96
|
+
requirement: *id005
|
97
|
+
name: rspec
|
98
|
+
description: Adds support to uri-templates in the dsl restfolia. See http://tools.ietf.org/html/rfc6570
|
99
|
+
email: nadilsons@gmail.com
|
100
|
+
executables: []
|
101
|
+
|
102
|
+
extensions: []
|
103
|
+
|
104
|
+
extra_rdoc_files: []
|
105
|
+
|
106
|
+
files:
|
107
|
+
- spec/fixtures/index.json
|
108
|
+
- spec/lib/restfolia/entry_point_spec.rb
|
109
|
+
- spec/lib/restfolia_spec.rb
|
110
|
+
- spec/spec_helper.rb
|
111
|
+
homepage: https://github.com/nadilsons/restfolia-uritemplate
|
112
|
+
licenses: []
|
113
|
+
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
|
117
|
+
require_paths:
|
118
|
+
- lib
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
hash: 3
|
125
|
+
segments:
|
126
|
+
- 0
|
127
|
+
version: "0"
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
hash: 3
|
134
|
+
segments:
|
135
|
+
- 0
|
136
|
+
version: "0"
|
137
|
+
requirements: []
|
138
|
+
|
139
|
+
rubyforge_project: restfolia-uritemplate
|
140
|
+
rubygems_version: 1.8.22
|
141
|
+
signing_key:
|
142
|
+
specification_version: 3
|
143
|
+
summary: Adds support to uri-templates in the dsl restfolia
|
144
|
+
test_files:
|
145
|
+
- spec/fixtures/index.json
|
146
|
+
- spec/lib/restfolia/entry_point_spec.rb
|
147
|
+
- spec/lib/restfolia_spec.rb
|
148
|
+
- spec/spec_helper.rb
|