francois-rest-client 1.1.5
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/README.rdoc +104 -0
- data/Rakefile +57 -0
- data/VERSION +1 -0
- data/bin/restclient +87 -0
- data/lib/rest_client.rb +2 -0
- data/lib/restclient/exceptions.rb +88 -0
- data/lib/restclient/mixin/response.rb +43 -0
- data/lib/restclient/net_http_ext.rb +21 -0
- data/lib/restclient/payload.rb +206 -0
- data/lib/restclient/raw_response.rb +30 -0
- data/lib/restclient/request.rb +241 -0
- data/lib/restclient/resource.rb +146 -0
- data/lib/restclient/response.rb +20 -0
- data/lib/restclient.rb +107 -0
- data/spec/base.rb +10 -0
- data/spec/exceptions_spec.rb +65 -0
- data/spec/master_shake.jpg +0 -0
- data/spec/mixin/response_spec.rb +46 -0
- data/spec/payload_spec.rb +76 -0
- data/spec/raw_response_spec.rb +17 -0
- data/spec/request_spec.rb +484 -0
- data/spec/resource_spec.rb +75 -0
- data/spec/response_spec.rb +16 -0
- data/spec/restclient_spec.rb +53 -0
- metadata +85 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/base'
|
2
|
+
|
3
|
+
describe RestClient do
|
4
|
+
describe "API" do
|
5
|
+
it "GET" do
|
6
|
+
RestClient::Request.should_receive(:execute).with(:method => :get, :url => 'http://some/resource', :headers => {})
|
7
|
+
RestClient.get('http://some/resource')
|
8
|
+
end
|
9
|
+
|
10
|
+
it "POST" do
|
11
|
+
RestClient::Request.should_receive(:execute).with(:method => :post, :url => 'http://some/resource', :payload => 'payload', :headers => {})
|
12
|
+
RestClient.post('http://some/resource', 'payload')
|
13
|
+
end
|
14
|
+
|
15
|
+
it "PUT" do
|
16
|
+
RestClient::Request.should_receive(:execute).with(:method => :put, :url => 'http://some/resource', :payload => 'payload', :headers => {})
|
17
|
+
RestClient.put('http://some/resource', 'payload')
|
18
|
+
end
|
19
|
+
|
20
|
+
it "DELETE" do
|
21
|
+
RestClient::Request.should_receive(:execute).with(:method => :delete, :url => 'http://some/resource', :headers => {})
|
22
|
+
RestClient.delete('http://some/resource')
|
23
|
+
end
|
24
|
+
|
25
|
+
it "HEAD" do
|
26
|
+
RestClient::Request.should_receive(:execute).with(:method => :head, :url => 'http://some/resource', :headers => {})
|
27
|
+
RestClient.head('http://some/resource')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "logging" do
|
32
|
+
after do
|
33
|
+
RestClient.log = nil
|
34
|
+
end
|
35
|
+
|
36
|
+
it "gets the log source from the RESTCLIENT_LOG environment variable" do
|
37
|
+
ENV.stub!(:[]).with('RESTCLIENT_LOG').and_return('from env')
|
38
|
+
RestClient.log = 'from class method'
|
39
|
+
RestClient.log.should == 'from env'
|
40
|
+
end
|
41
|
+
|
42
|
+
it "sets a destination for log output, used if no environment variable is set" do
|
43
|
+
ENV.stub!(:[]).with('RESTCLIENT_LOG').and_return(nil)
|
44
|
+
RestClient.log = 'from class method'
|
45
|
+
RestClient.log.should == 'from class method'
|
46
|
+
end
|
47
|
+
|
48
|
+
it "returns nil (no logging) if neither are set (default)" do
|
49
|
+
ENV.stub!(:[]).with('RESTCLIENT_LOG').and_return(nil)
|
50
|
+
RestClient.log.should == nil
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: francois-rest-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Adam Wiggins
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-08-12 00:00:00 -07:00
|
13
|
+
default_executable: restclient
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: "A simple REST client for Ruby, inspired by the Sinatra microframework style of specifying actions: get, put, post, delete."
|
17
|
+
email: adam@heroku.com
|
18
|
+
executables:
|
19
|
+
- restclient
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.rdoc
|
24
|
+
files:
|
25
|
+
- README.rdoc
|
26
|
+
- Rakefile
|
27
|
+
- VERSION
|
28
|
+
- bin/restclient
|
29
|
+
- lib/rest_client.rb
|
30
|
+
- lib/restclient.rb
|
31
|
+
- lib/restclient/exceptions.rb
|
32
|
+
- lib/restclient/mixin/response.rb
|
33
|
+
- lib/restclient/net_http_ext.rb
|
34
|
+
- lib/restclient/payload.rb
|
35
|
+
- lib/restclient/raw_response.rb
|
36
|
+
- lib/restclient/request.rb
|
37
|
+
- lib/restclient/resource.rb
|
38
|
+
- lib/restclient/response.rb
|
39
|
+
- spec/base.rb
|
40
|
+
- spec/exceptions_spec.rb
|
41
|
+
- spec/master_shake.jpg
|
42
|
+
- spec/mixin/response_spec.rb
|
43
|
+
- spec/payload_spec.rb
|
44
|
+
- spec/raw_response_spec.rb
|
45
|
+
- spec/request_spec.rb
|
46
|
+
- spec/resource_spec.rb
|
47
|
+
- spec/response_spec.rb
|
48
|
+
- spec/restclient_spec.rb
|
49
|
+
has_rdoc: false
|
50
|
+
homepage: http://rest-client.heroku.com/
|
51
|
+
licenses:
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options:
|
54
|
+
- --charset=UTF-8
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: "0"
|
62
|
+
version:
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
version:
|
69
|
+
requirements: []
|
70
|
+
|
71
|
+
rubyforge_project: rest-client
|
72
|
+
rubygems_version: 1.3.5
|
73
|
+
signing_key:
|
74
|
+
specification_version: 3
|
75
|
+
summary: Simple REST client for Ruby, inspired by microframework syntax for specifying actions.
|
76
|
+
test_files:
|
77
|
+
- spec/base.rb
|
78
|
+
- spec/exceptions_spec.rb
|
79
|
+
- spec/mixin/response_spec.rb
|
80
|
+
- spec/payload_spec.rb
|
81
|
+
- spec/raw_response_spec.rb
|
82
|
+
- spec/request_spec.rb
|
83
|
+
- spec/resource_spec.rb
|
84
|
+
- spec/response_spec.rb
|
85
|
+
- spec/restclient_spec.rb
|