restrack-client 0.1.4 → 1.0.0
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/.document +0 -0
- data/Gemfile +0 -0
- data/Gemfile.lock +0 -0
- data/README.markdown +0 -0
- data/Rakefile +0 -0
- data/lib/restrack-client.rb +1 -6
- data/lib/restrack-client/version.rb +1 -1
- data/restrack-client.gemspec +0 -0
- data/test/helper.rb +0 -0
- data/test/test_app/config.ru +0 -0
- data/test/test_app/config/constants.yaml +0 -0
- data/test/test_app/controllers/parent_controller.rb +0 -0
- data/test/test_app/controllers/responses_controller.rb +0 -0
- data/test/test_app/loader.rb +0 -0
- data/test/test_restrack-client.rb +31 -7
- metadata +2 -2
data/.document
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/Gemfile.lock
CHANGED
File without changes
|
data/README.markdown
CHANGED
File without changes
|
data/Rakefile
CHANGED
File without changes
|
data/lib/restrack-client.rb
CHANGED
@@ -64,12 +64,8 @@ module RESTRack
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def send(request)
|
67
|
+
@path = ''
|
67
68
|
response = Net::HTTP.start(@uri.host, @uri.port) { |http| http.request(request) }
|
68
|
-
unless response.kind_of?(Net::HTTPSuccess)
|
69
|
-
e = RuntimeError.new("#{request.method} #{request.path} - #{res.code}:#{res.message}\n#{res.body}")
|
70
|
-
raise e
|
71
|
-
end
|
72
|
-
response
|
73
69
|
end
|
74
70
|
|
75
71
|
def parse(response)
|
@@ -92,4 +88,3 @@ module RESTRack
|
|
92
88
|
end
|
93
89
|
MIME::Types['text/plain'][0].extensions << 'text'
|
94
90
|
MIME::Types.index_extensions( MIME::Types['text/plain'][0] )
|
95
|
-
# -------------------------------------------------------/
|
data/restrack-client.gemspec
CHANGED
File without changes
|
data/test/helper.rb
CHANGED
File without changes
|
data/test/test_app/config.ru
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/test/test_app/loader.rb
CHANGED
File without changes
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.join( File.dirname(__FILE__ ), 'helper' )
|
2
2
|
|
3
3
|
class TestRESTRackClient < Test::Unit::TestCase
|
4
|
-
|
4
|
+
|
5
5
|
context 'instantiation' do
|
6
6
|
should 'accept a String URI' do
|
7
7
|
assert_nothing_raised { client_1 = RESTRack::Client.new('http://localhost:9292') }
|
@@ -11,7 +11,7 @@ class TestRESTRackClient < Test::Unit::TestCase
|
|
11
11
|
assert_nothing_raised { client_2 = RESTRack::Client.new(uri) }
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
should 'get a resource' do
|
16
16
|
client = RESTRack::Client.new('http://localhost:9292')
|
17
17
|
get_response = nil
|
@@ -30,7 +30,7 @@ class TestRESTRackClient < Test::Unit::TestCase
|
|
30
30
|
expected_response = { 'action' => 'index' }
|
31
31
|
assert_equal expected_response, get_response
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
should 'delete a resource' do
|
35
35
|
client = RESTRack::Client.new('http://localhost:9292')
|
36
36
|
delete_response = nil
|
@@ -49,7 +49,7 @@ class TestRESTRackClient < Test::Unit::TestCase
|
|
49
49
|
expected_response = { 'action' => 'destroy' }
|
50
50
|
assert_equal expected_response, delete_response
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
should 'post a resource' do
|
54
54
|
client = RESTRack::Client.new('http://localhost:9292')
|
55
55
|
post_response = nil
|
@@ -74,7 +74,7 @@ class TestRESTRackClient < Test::Unit::TestCase
|
|
74
74
|
expected_response = { 'action' => 'create', 'data' => data }
|
75
75
|
assert_equal expected_response, post_response
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
should 'put a resource' do
|
79
79
|
client = RESTRack::Client.new('http://localhost:9292')
|
80
80
|
put_response = nil
|
@@ -99,7 +99,7 @@ class TestRESTRackClient < Test::Unit::TestCase
|
|
99
99
|
expected_response = { 'action' => 'replace', 'data' => data }
|
100
100
|
assert_equal expected_response, put_response
|
101
101
|
end
|
102
|
-
|
102
|
+
|
103
103
|
should 'send and parse response json data' do
|
104
104
|
client = RESTRack::Client.new('http://localhost:9292', :JSON)
|
105
105
|
post_response = nil
|
@@ -164,5 +164,29 @@ class TestRESTRackClient < Test::Unit::TestCase
|
|
164
164
|
expected_response = { 'action' => 'add', 'id' => '1', 'data' => data }
|
165
165
|
assert_equal expected_response, post_response
|
166
166
|
end
|
167
|
-
|
167
|
+
|
168
|
+
should 'handle multiple sequential requests' do
|
169
|
+
client = RESTRack::Client.new('http://localhost:9292')
|
170
|
+
get_response = nil
|
171
|
+
assert_nothing_raised do
|
172
|
+
get_response = client.responses(1).get
|
173
|
+
end
|
174
|
+
expected_response = { 'action' => 'show', 'id' => '1' }
|
175
|
+
assert_equal expected_response, get_response
|
176
|
+
|
177
|
+
get_response = nil
|
178
|
+
assert_nothing_raised do
|
179
|
+
get_response = client.responses(1).get
|
180
|
+
end
|
181
|
+
expected_response = { 'action' => 'show', 'id' => '1' }
|
182
|
+
assert_equal expected_response, get_response
|
183
|
+
|
184
|
+
get_response = nil
|
185
|
+
assert_nothing_raised do
|
186
|
+
get_response = client.responses(1).get
|
187
|
+
end
|
188
|
+
expected_response = { 'action' => 'show', 'id' => '1' }
|
189
|
+
assert_equal expected_response, get_response
|
190
|
+
end
|
191
|
+
|
168
192
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: restrack-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 1.0.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Chris St. John
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-05-18 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|