realweb 0.1.0 → 0.1.4
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 +36 -13
- data/lib/realweb/server.rb +0 -1
- metadata +6 -6
data/README.rdoc
CHANGED
@@ -1,24 +1,47 @@
|
|
1
1
|
= RealWeb
|
2
2
|
|
3
|
-
Boot a rack app
|
3
|
+
Boot a rack app to use as a real endpoint for tests.
|
4
4
|
|
5
|
-
|
5
|
+
== Why?
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
We found this very useful for gems that hit an API. Rather than mocking out all
|
8
|
+
the URIs with FakeWeb, you can just write a sample rack app that looks like the
|
9
|
+
API you're expecting. It's not uncommon to have 5+ different small rack apps
|
10
|
+
that reflect different behaviors of your remote server. We created things like
|
11
|
+
broken.ru that always responds with 500s, forbidden.ru that is always 403, and
|
12
|
+
healthy.ru that always returns happy path responses.
|
10
13
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
+
Another useful way to use this is with paired client/server libraries. We use
|
15
|
+
RealWeb to boot up the real rack server and hit it with the client from within
|
16
|
+
the specs.
|
17
|
+
|
18
|
+
== Usage
|
19
|
+
|
20
|
+
# fixtures/config.ru
|
21
|
+
run lambda { |env| [200, { 'Content-Type' => 'application/json' }, '[{thing: 1}, {thing: 2}]'] }
|
22
|
+
|
23
|
+
# thing_api_spec.rb
|
24
|
+
describe MyLibrary do
|
25
|
+
before(:each) do
|
26
|
+
@server = RealWeb.start_server("fixtures/config.ru")
|
27
|
+
end
|
14
28
|
|
15
|
-
|
16
|
-
|
29
|
+
after(:each) do
|
30
|
+
@server.stop
|
31
|
+
end
|
32
|
+
|
33
|
+
it "runs an action that would normally hit the api" do
|
34
|
+
MyLibrary.get_list_of_things_from_api(@server.base_uri).should_not be_empty
|
35
|
+
end
|
17
36
|
end
|
18
37
|
|
19
38
|
|
20
|
-
RealWeb.start_server boots the given config.ru in a thread. When you call stop
|
39
|
+
RealWeb.start_server boots the given config.ru in a thread. When you call stop
|
40
|
+
on the server object, the server is killed.
|
21
41
|
|
22
|
-
|
42
|
+
The example uses an extremely simplistic rack app. We usually use Sinatra apps
|
43
|
+
for RealWeb backends.
|
23
44
|
|
24
|
-
|
45
|
+
== Forking Server
|
46
|
+
|
47
|
+
You can specifically use a Process.fork server with start_server_in_fork.
|
data/lib/realweb/server.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: realweb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ben Burkert
|
@@ -17,11 +17,10 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2010-
|
20
|
+
date: 2010-06-01 00:00:00 -07:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
24
|
-
prerelease: false
|
25
24
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
26
25
|
none: false
|
27
26
|
requirements:
|
@@ -34,8 +33,9 @@ dependencies:
|
|
34
33
|
- 0
|
35
34
|
version: 1.1.0
|
36
35
|
requirement: *id001
|
37
|
-
type: :runtime
|
38
36
|
name: rack
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
39
|
description: Easily runs a rack app for tests that hit web APIs
|
40
40
|
email: cloud-engineering@engineyard.com
|
41
41
|
executables: []
|