igrigorik-em-http-request 0.1.5 → 0.1.6

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.
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'em-http-request'
3
- s.version = '0.1.5'
3
+ s.version = '0.1.6'
4
4
  s.date = '2009-03-20'
5
5
  s.summary = 'EventMachine based HTTP Request interface'
6
6
  s.description = s.summary
@@ -27,7 +27,7 @@ module EventMachine
27
27
 
28
28
  def initialize(host, headers = {})
29
29
  @headers = headers
30
- @uri = URI::parse(host) unless host.kind_of? URI
30
+ @uri = host.kind_of?(URI) ? host : URI::parse(host)
31
31
  end
32
32
 
33
33
  # Send an HTTP request and consume the response. Supported options:
data/test/test_request.rb CHANGED
@@ -53,6 +53,20 @@ describe EventMachine::HttpRequest do
53
53
  }
54
54
  }
55
55
  end
56
+
57
+ it "should perform successfull GET with a URI passed as argument" do
58
+ EventMachine.run {
59
+ uri = URI.parse('http://127.0.0.1:8080/')
60
+ http = EventMachine::HttpRequest.new(uri).get
61
+
62
+ http.errback { failed }
63
+ http.callback {
64
+ http.response_header.status.should == 200
65
+ http.response.should match(/Hello/)
66
+ EventMachine.stop
67
+ }
68
+ }
69
+ end
56
70
 
57
71
  it "should return 404 on invalid path" do
58
72
  EventMachine.run {
@@ -262,4 +276,5 @@ describe EventMachine::HttpRequest do
262
276
  }
263
277
  }
264
278
  end
279
+
265
280
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: igrigorik-em-http-request
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Grigorik