rack-stubs 0.0.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +8 -0
- data/README.rdoc +41 -3
- data/lib/rack_stubs.rb +1 -1
- data/rack-stubs.gemspec +6 -5
- metadata +28 -28
data/LICENSE
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
Copyright (c) 2011, Featurist
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
5
|
+
|
6
|
+
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
7
|
+
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
8
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.rdoc
CHANGED
@@ -1,7 +1,45 @@
|
|
1
1
|
= Rack Stubs
|
2
2
|
|
3
|
-
Rack middleware for
|
3
|
+
Rack middleware for stubbing responses from HTTP web services.
|
4
4
|
|
5
|
-
==
|
5
|
+
== Installation
|
6
6
|
|
7
|
-
|
7
|
+
gem install rack-stubs
|
8
|
+
|
9
|
+
== Using the server middleware
|
10
|
+
|
11
|
+
rack-stubs is implemented as rack middleware, so you would typically host it as part of a rack web app. You can write a rack configuration (config.ru) like this if you want to get started:
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'rack-stubs'
|
15
|
+
|
16
|
+
use RackStubs::Middleware
|
17
|
+
run lambda { |e| [404, { 'Content-Type' => 'text/plain' }, ["Not found"]] }
|
18
|
+
|
19
|
+
Then you can run the rackup binary:
|
20
|
+
|
21
|
+
rackup
|
22
|
+
|
23
|
+
...and you'll have a server with rack-stubs running at http://127.0.0.1:9292
|
24
|
+
|
25
|
+
To create a stub response, let's say we want HTTP GET requests to /foo to return an HTTP 200 status, with the body "bar" and the content type "text/plain". Using a REST tool of some kind (you could use the rest-client ruby gem or the poster firefox plugin) you can now set this up by making the following HTTP request:
|
26
|
+
|
27
|
+
method : POST
|
28
|
+
action : http://127.0.0.1:9292/foo
|
29
|
+
body : { "GET" : [200, { "Content-Type": "text/plain" }, ["bar"]] }
|
30
|
+
headers : Content-Type=application/json+rack-stub
|
31
|
+
|
32
|
+
All subsequent requests to http://127.0.0.1:9292/foo should now respond with HTTP 200 status, Content-Type=text/plain and the body "bar". The body is json, but it's essentially implemented as a hash of simple rack-style response tuples.
|
33
|
+
|
34
|
+
You can also see a list of all stub responses via GET /rack_stubs/list and clear all stub responses via POST /rack_stubs/clear
|
35
|
+
|
36
|
+
== Using the client
|
37
|
+
|
38
|
+
To use rack-stubs from Ruby without diving down into REST, rack-stubs includes a small client library. To set up the same behaviour as specified above, you would use the client like this:
|
39
|
+
|
40
|
+
client = RackStubs::Client.new("http://127.0.0.1:9292")
|
41
|
+
client.get("/foo").returns(200, { "Content-Type" => "text/plain" }, "bar")
|
42
|
+
|
43
|
+
You might want to clear all stub responses, say between test cases, like so:
|
44
|
+
|
45
|
+
client.clear_all!
|
data/lib/rack_stubs.rb
CHANGED
data/rack-stubs.gemspec
CHANGED
@@ -5,18 +5,19 @@ require "rack_stubs"
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = 'rack-stubs'
|
7
7
|
s.version = RackStubs::VERSION
|
8
|
-
s.authors = ['
|
9
|
-
s.description = '
|
8
|
+
s.authors = ['featurist.co.uk']
|
9
|
+
s.description = 'Rack middleware for stubbing responses from HTTP web services'
|
10
10
|
s.summary = "rack-stubs-#{s.version}"
|
11
|
-
s.email = '
|
12
|
-
s.homepage = 'http://github.com/
|
11
|
+
s.email = 'enquiries@featurist.co.uk'
|
12
|
+
s.homepage = 'http://github.com/featurist/rack-stubs'
|
13
13
|
|
14
14
|
s.add_dependency 'json', '~> 1.4.6'
|
15
15
|
s.add_dependency 'rack', '~> 1.3.1'
|
16
|
-
s.add_dependency 'rest-client', '~> 1.
|
16
|
+
s.add_dependency 'rest-client', '~> 1.6.3'
|
17
17
|
|
18
18
|
s.add_development_dependency 'rspec', '~> 2.2.0'
|
19
19
|
s.add_development_dependency 'cucumber', '~> 0.10.0'
|
20
|
+
s.add_development_dependency 'mongrel', '~> 1.1.5'
|
20
21
|
|
21
22
|
s.rubygems_version = "1.3.7"
|
22
23
|
s.files = `git ls-files`.split("\n")
|
metadata
CHANGED
@@ -1,32 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-stubs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
4
|
+
prerelease: false
|
6
5
|
segments:
|
6
|
+
- 1
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.3
|
9
|
+
version: 1.0.0
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
|
-
-
|
12
|
+
- featurist.co.uk
|
14
13
|
autorequire:
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2011-
|
17
|
+
date: 2011-09-06 00:00:00 +01:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: json
|
23
22
|
prerelease: false
|
24
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
24
|
requirements:
|
27
25
|
- - ~>
|
28
26
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 11
|
30
27
|
segments:
|
31
28
|
- 1
|
32
29
|
- 4
|
@@ -38,11 +35,9 @@ dependencies:
|
|
38
35
|
name: rack
|
39
36
|
prerelease: false
|
40
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
38
|
requirements:
|
43
39
|
- - ~>
|
44
40
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 25
|
46
41
|
segments:
|
47
42
|
- 1
|
48
43
|
- 3
|
@@ -54,27 +49,23 @@ dependencies:
|
|
54
49
|
name: rest-client
|
55
50
|
prerelease: false
|
56
51
|
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
52
|
requirements:
|
59
53
|
- - ~>
|
60
54
|
- !ruby/object:Gem::Version
|
61
|
-
hash: 3
|
62
55
|
segments:
|
63
56
|
- 1
|
64
|
-
-
|
65
|
-
-
|
66
|
-
version: 1.
|
57
|
+
- 6
|
58
|
+
- 3
|
59
|
+
version: 1.6.3
|
67
60
|
type: :runtime
|
68
61
|
version_requirements: *id003
|
69
62
|
- !ruby/object:Gem::Dependency
|
70
63
|
name: rspec
|
71
64
|
prerelease: false
|
72
65
|
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
66
|
requirements:
|
75
67
|
- - ~>
|
76
68
|
- !ruby/object:Gem::Version
|
77
|
-
hash: 7
|
78
69
|
segments:
|
79
70
|
- 2
|
80
71
|
- 2
|
@@ -86,11 +77,9 @@ dependencies:
|
|
86
77
|
name: cucumber
|
87
78
|
prerelease: false
|
88
79
|
requirement: &id005 !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
80
|
requirements:
|
91
81
|
- - ~>
|
92
82
|
- !ruby/object:Gem::Version
|
93
|
-
hash: 55
|
94
83
|
segments:
|
95
84
|
- 0
|
96
85
|
- 10
|
@@ -98,8 +87,22 @@ dependencies:
|
|
98
87
|
version: 0.10.0
|
99
88
|
type: :development
|
100
89
|
version_requirements: *id005
|
101
|
-
|
102
|
-
|
90
|
+
- !ruby/object:Gem::Dependency
|
91
|
+
name: mongrel
|
92
|
+
prerelease: false
|
93
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ~>
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
segments:
|
98
|
+
- 1
|
99
|
+
- 1
|
100
|
+
- 5
|
101
|
+
version: 1.1.5
|
102
|
+
type: :development
|
103
|
+
version_requirements: *id006
|
104
|
+
description: Rack middleware for stubbing responses from HTTP web services
|
105
|
+
email: enquiries@featurist.co.uk
|
103
106
|
executables: []
|
104
107
|
|
105
108
|
extensions: []
|
@@ -109,6 +112,7 @@ extra_rdoc_files:
|
|
109
112
|
files:
|
110
113
|
- .gitignore
|
111
114
|
- Gemfile
|
115
|
+
- LICENSE
|
112
116
|
- README.rdoc
|
113
117
|
- features/step_definitions/steps.rb
|
114
118
|
- features/stub_responses.feature
|
@@ -123,7 +127,7 @@ files:
|
|
123
127
|
- spec/rack_stubs/middleware_spec.rb
|
124
128
|
- spec/spec_helper.rb
|
125
129
|
has_rdoc: true
|
126
|
-
homepage: http://github.com/
|
130
|
+
homepage: http://github.com/featurist/rack-stubs
|
127
131
|
licenses: []
|
128
132
|
|
129
133
|
post_install_message:
|
@@ -132,29 +136,25 @@ rdoc_options: []
|
|
132
136
|
require_paths:
|
133
137
|
- lib
|
134
138
|
required_ruby_version: !ruby/object:Gem::Requirement
|
135
|
-
none: false
|
136
139
|
requirements:
|
137
140
|
- - ">="
|
138
141
|
- !ruby/object:Gem::Version
|
139
|
-
hash: 3
|
140
142
|
segments:
|
141
143
|
- 0
|
142
144
|
version: "0"
|
143
145
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
|
-
none: false
|
145
146
|
requirements:
|
146
147
|
- - ">="
|
147
148
|
- !ruby/object:Gem::Version
|
148
|
-
hash: 3
|
149
149
|
segments:
|
150
150
|
- 0
|
151
151
|
version: "0"
|
152
152
|
requirements: []
|
153
153
|
|
154
154
|
rubyforge_project:
|
155
|
-
rubygems_version: 1.
|
155
|
+
rubygems_version: 1.3.6
|
156
156
|
signing_key:
|
157
157
|
specification_version: 3
|
158
|
-
summary: rack-stubs-0.0
|
158
|
+
summary: rack-stubs-1.0.0
|
159
159
|
test_files: []
|
160
160
|
|