ww 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +3 -0
- data/lib/ww.rb +5 -1
- data/spec/usage/spy_spec.rb +43 -0
- data/spec/usage/stub_spec.rb +27 -0
- metadata +5 -3
data/ChangeLog
CHANGED
data/lib/ww.rb
CHANGED
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.expand_path("../spec_helper", File.dirname(__FILE__))
|
2
|
+
require 'ww/server'
|
3
|
+
require 'open-uri'
|
4
|
+
|
5
|
+
describe "Ww::Server.spy learning" do
|
6
|
+
before(:all) do
|
7
|
+
@@spy_server ||= Ww::Server.build_double(3082) do
|
8
|
+
spy.get("/hello") { "Hello World." }
|
9
|
+
end
|
10
|
+
@@spy_server.start_once
|
11
|
+
end
|
12
|
+
|
13
|
+
context "GET /hello" do
|
14
|
+
before do
|
15
|
+
@respose = URI("http://localhost:3082/hello").read
|
16
|
+
end
|
17
|
+
|
18
|
+
it "the server should requesed to /hello" do
|
19
|
+
req = @@spy_server.requests.first
|
20
|
+
|
21
|
+
req.path.should == "/hello"
|
22
|
+
end
|
23
|
+
|
24
|
+
it "get greeting message" do
|
25
|
+
@respose.strip.should == "Hello World."
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "POST /greet" do
|
30
|
+
before do
|
31
|
+
# can define outside of block
|
32
|
+
@@spy_server.spy.post("/greet") { status(200) }
|
33
|
+
|
34
|
+
# POST from other process, ok it's fully functional server.
|
35
|
+
system("curl -s -o /dev/null -d lang=ja -d message=konnichiwa http://localhost:3082/greet")
|
36
|
+
end
|
37
|
+
subject{ @@spy_server.requests.first }
|
38
|
+
|
39
|
+
its(:request_method){ should == "POST" }
|
40
|
+
its(:parsed_body){ should == {"lang" => "ja", "message" => "konnichiwa" } }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.expand_path("../spec_helper", File.dirname(__FILE__))
|
2
|
+
require 'ww/server'
|
3
|
+
require 'open-uri'
|
4
|
+
|
5
|
+
describe "Ww::Server.stub learning" do
|
6
|
+
before(:all) do
|
7
|
+
@@stub_server ||= Ww::Server.build_double(3081) do
|
8
|
+
stub.get("/hello") { "Hello World." }
|
9
|
+
end
|
10
|
+
|
11
|
+
@@stub_server.start_once
|
12
|
+
end
|
13
|
+
|
14
|
+
it "get greeting message" do
|
15
|
+
URI("http://localhost:3081/hello").read.strip.should == "Hello World."
|
16
|
+
end
|
17
|
+
|
18
|
+
context "overwride stub w/ japanese one" do
|
19
|
+
before do
|
20
|
+
@@stub_server.stub.get("/hello") { "Kon-nichiwa Sekai" }
|
21
|
+
end
|
22
|
+
|
23
|
+
it "get greeting message in Japanese" do
|
24
|
+
URI("http://localhost:3081/hello").read.strip.should == "Kon-nichiwa Sekai"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 0.4.
|
8
|
+
- 1
|
9
|
+
version: 0.4.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- moro
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-03-09 00:00:00 +09:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -87,6 +87,8 @@ files:
|
|
87
87
|
- MIT-LICENSE
|
88
88
|
- Rakefile
|
89
89
|
- spec/spec_helper.rb
|
90
|
+
- spec/usage/spy_spec.rb
|
91
|
+
- spec/usage/stub_spec.rb
|
90
92
|
- spec/ww/application_spec.rb
|
91
93
|
- spec/ww/double/mock/expectation_spec.rb
|
92
94
|
- spec/ww/double/mock_spec.rb
|