hypertext_client 0.0.7 → 0.0.8
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.
- data/CHANGELOG +4 -0
- data/lib/hypertext_client/hypertext_client.rb +5 -4
- data/test/test_hypertext_client.rb +22 -2
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
# Hypertext provides an HTTP client based on HTTParty, with a few assumptions baked in.
|
20
20
|
module HypertextClient
|
21
|
-
VERSION = '0.0.
|
21
|
+
VERSION = '0.0.8'
|
22
22
|
|
23
23
|
extend ActiveSupport::Concern
|
24
24
|
# Include HTTParty
|
@@ -105,10 +105,11 @@ module HypertextClient
|
|
105
105
|
end
|
106
106
|
|
107
107
|
path = args.shift
|
108
|
-
|
109
|
-
path =
|
108
|
+
unless (path.is_a?(Hash) || path.is_a?(Array))
|
109
|
+
path = path.to_s
|
110
|
+
path = '/' + path unless path.nil? || path =~ %r(http://) || path.chars.first == '/'
|
110
111
|
else
|
111
|
-
args.unshift path
|
112
|
+
args.unshift path
|
112
113
|
path = ''
|
113
114
|
end
|
114
115
|
|
@@ -12,7 +12,7 @@ FAKE_ENDPOINT = "http://api.skynetinc.com"
|
|
12
12
|
|
13
13
|
FakeWeb.allow_net_connect = false
|
14
14
|
FakeWeb.register_uri(:get,
|
15
|
-
FAKE_ENDPOINT + '/widgets',
|
15
|
+
FAKE_ENDPOINT + '/widgets/?',
|
16
16
|
:body => ([{:foo => 1}] * 5).to_json,
|
17
17
|
:content_type => 'application/json')
|
18
18
|
|
@@ -42,7 +42,12 @@ FakeWeb.register_uri(:get,
|
|
42
42
|
:body => {:property => 'exists'}.to_json,
|
43
43
|
:content_type => 'application/json')
|
44
44
|
|
45
|
-
FakeWeb.register_uri(:
|
45
|
+
FakeWeb.register_uri(:any,
|
46
|
+
FAKE_ENDPOINT + '/camel_cases/example/camel_case_inheritors',
|
47
|
+
:body => [{:property => 'exists'}].to_json,
|
48
|
+
:content_type => 'application/json')
|
49
|
+
|
50
|
+
FakeWeb.register_uri(:any,
|
46
51
|
FAKE_ENDPOINT + '/camel_cases/example/camel_case_inheritors/123',
|
47
52
|
:body => {:property => 'exists'}.to_json,
|
48
53
|
:content_type => 'application/json')
|
@@ -146,4 +151,19 @@ class HypertextClientTest < MiniTest::Unit::TestCase
|
|
146
151
|
example = SkynetClient::CamelCaseInheritor.get('123', :camel_case => 'example')
|
147
152
|
assert example
|
148
153
|
end
|
154
|
+
|
155
|
+
def test_requires_camelcase_id
|
156
|
+
example = SkynetClient::CamelCaseInheritor.delete('123', :camel_case => 'example')
|
157
|
+
assert_equal '/camel_cases/example/camel_case_inheritors/123', FakeWeb.last_request.path
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_build_url_non_string_for_sub_model
|
161
|
+
example = SkynetClient::CamelCaseInheritor.delete(123, :camel_case => 'example')
|
162
|
+
assert_equal '/camel_cases/example/camel_case_inheritors/123', FakeWeb.last_request.path
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_build_collection_url_from_hash_for_sub_model
|
166
|
+
example = SkynetClient::CamelCaseInheritor.get(:camel_case => 'example')
|
167
|
+
assert_equal '/camel_cases/example/camel_case_inheritors', FakeWeb.last_request.path
|
168
|
+
end
|
149
169
|
end
|