alice 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{alice}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["rick"]
12
- s.date = %q{2010-01-07}
12
+ s.date = %q{2010-01-08}
13
13
  s.description = %q{HTTP/REST API client library using Rack-like middleware}
14
14
  s.email = %q{technoweenie@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -9,8 +9,6 @@ module Alice
9
9
  full_path = full_path_for(env[:url].path, env[:url].query, env[:url].fragment)
10
10
  http_resp = http.send_request(env[:method].to_s.upcase, full_path, env[:body], env[:request_headers])
11
11
 
12
- raise Error::ResourceNotFound if http_resp.code == '404'
13
-
14
12
  resp_headers = {}
15
13
  http_resp.each_header do |key, value|
16
14
  resp_headers[key] = value
@@ -17,8 +17,6 @@ module Alice
17
17
  end
18
18
  resp = sess.send *args
19
19
 
20
- raise Alice::Error::ResourceNotFound if resp.status == 404
21
-
22
20
  env.update \
23
21
  :status => resp.status,
24
22
  :response_headers => resp.headers.
@@ -41,11 +41,11 @@ module Alice
41
41
  new_stub(:head, path, &block)
42
42
  end
43
43
 
44
- def post(path, body, &block)
44
+ def post(path, body=nil, &block)
45
45
  new_stub(:post, path, body, &block)
46
46
  end
47
47
 
48
- def put(path, body, &block)
48
+ def put(path, body=nil, &block)
49
49
  new_stub(:put, path, body, &block)
50
50
  end
51
51
 
@@ -23,7 +23,6 @@ module Alice
23
23
  :headers => env[:request_headers]
24
24
 
25
25
  req.on_complete do |resp|
26
- raise Alice::Error::ResourceNotFound if resp.code == 404
27
26
  env.update \
28
27
  :status => resp.code,
29
28
  :response_headers => parse_response_headers(resp.headers),
@@ -45,5 +45,9 @@ module Alice
45
45
  @status, @headers, @body = env[:status], env[:response_headers], env[:body]
46
46
  self
47
47
  end
48
+
49
+ def success?
50
+ status == 200
51
+ end
48
52
  end
49
- end
53
+ end
@@ -9,7 +9,7 @@ class RequestMiddlewareTest < Alice::TestCase
9
9
  @connection = Alice::Connection.new do |b|
10
10
  b.use encoder
11
11
  b.adapter :test do |stub|
12
- stub.post('echo_body') { |env| [200, {'Content-Type' => 'text/html'}, env[:body]] }
12
+ stub.post('echo_body', '{"a":1}') { |env| [200, {'Content-Type' => 'text/html'}, env[:body]] }
13
13
  end
14
14
  end
15
15
  assert_equal %({"a":1}), @connection.post('echo_body', :a => 1).body
@@ -12,7 +12,9 @@ class ResponseMiddlewareTest < Alice::TestCase
12
12
  end
13
13
  b.use parser
14
14
  end
15
- assert_equal [1,2,3], @connection.get('json').body
15
+ response = @connection.get('json')
16
+ assert response.success?
17
+ assert_equal [1,2,3], response.body
16
18
  end
17
19
  end
18
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alice
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - rick
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-07 00:00:00 -08:00
12
+ date: 2010-01-08 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency