riot-gear 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +10 -0
- data/.yardopts +6 -0
- data/CHANGELOG +39 -0
- data/Gemfile +9 -0
- data/MIT-LICENSE +20 -0
- data/README.md +79 -6
- data/Rakefile +4 -24
- data/lib/riot/gear/context/asserts_header.rb +6 -0
- data/lib/riot/gear/context/asserts_json.rb +21 -7
- data/lib/riot/gear/context/asserts_status.rb +6 -0
- data/lib/riot/gear/context/persist_cookie.rb +17 -0
- data/lib/riot/gear/middleware/riotparty.rb +81 -24
- data/lib/riot/gear/version.rb +6 -0
- data/riot-gear.gemspec +14 -71
- data/test/actions/delete_test.rb +54 -45
- data/test/actions/get_test.rb +95 -36
- data/test/actions/post_test.rb +55 -45
- data/test/actions/put_test.rb +54 -45
- data/test/assertions/asserts_json_test.rb +2 -2
- data/test/helpers/cookie_values_test.rb +10 -6
- data/test/riotparty_proxy_methods_test.rb +1 -1
- data/test/setting_up_gear_context_test.rb +4 -3
- data/test/teststrap.rb +2 -0
- metadata +55 -81
- data/VERSION +0 -1
data/riot-gear.gemspec
CHANGED
@@ -1,78 +1,21 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.unshift(File.expand_path("../lib", __FILE__))
|
3
|
+
require "riot/gear/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
9
|
-
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.
|
13
|
-
s.
|
14
|
-
s.
|
15
|
-
s.
|
16
|
-
"README.md"
|
17
|
-
]
|
18
|
-
s.files = [
|
19
|
-
"README.md",
|
20
|
-
"Rakefile",
|
21
|
-
"VERSION",
|
22
|
-
"lib/riot/gear.rb",
|
23
|
-
"lib/riot/gear/context.rb",
|
24
|
-
"lib/riot/gear/context/asserts_header.rb",
|
25
|
-
"lib/riot/gear/context/asserts_json.rb",
|
26
|
-
"lib/riot/gear/context/asserts_status.rb",
|
27
|
-
"lib/riot/gear/context/persist_cookie.rb",
|
28
|
-
"lib/riot/gear/middleware.rb",
|
29
|
-
"lib/riot/gear/middleware/riotparty.rb",
|
30
|
-
"riot-gear.gemspec",
|
31
|
-
"test/actions/delete_test.rb",
|
32
|
-
"test/actions/get_test.rb",
|
33
|
-
"test/actions/post_test.rb",
|
34
|
-
"test/actions/put_test.rb",
|
35
|
-
"test/assertions/asserts_json_test.rb",
|
36
|
-
"test/helpers/cookie_values_test.rb",
|
37
|
-
"test/helpers/json_path_test.rb",
|
38
|
-
"test/riotparty_proxy_methods_test.rb",
|
39
|
-
"test/setting_up_gear_context_test.rb",
|
40
|
-
"test/teststrap.rb"
|
41
|
-
]
|
42
|
-
s.homepage = %q{http://github.com/thumblemonks/riot-gear}
|
6
|
+
s.name = %q{riot-gear}
|
7
|
+
s.version = Riot::Gear::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Justin 'Gus' Knowlden"]
|
10
|
+
s.summary = %q{Riot + HTTParty smoke testing framework.}
|
11
|
+
s.description = %q{Riot + HTTParty smoke testing framework. You'd use it for integration testing with real HTTP requests and responses}
|
12
|
+
s.email = %q{gus@gusg.us}
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.homepage = %q{http://github.com/thumblemonks/riot-gear}
|
43
15
|
s.require_paths = ["lib"]
|
44
|
-
s.
|
45
|
-
s.summary = %q{Riot + HTTParty smoke testing framework}
|
46
|
-
s.test_files = [
|
47
|
-
"test/actions/delete_test.rb",
|
48
|
-
"test/actions/get_test.rb",
|
49
|
-
"test/actions/post_test.rb",
|
50
|
-
"test/actions/put_test.rb",
|
51
|
-
"test/assertions/asserts_json_test.rb",
|
52
|
-
"test/helpers/cookie_values_test.rb",
|
53
|
-
"test/helpers/json_path_test.rb",
|
54
|
-
"test/riotparty_proxy_methods_test.rb",
|
55
|
-
"test/setting_up_gear_context_test.rb",
|
56
|
-
"test/teststrap.rb"
|
57
|
-
]
|
58
|
-
|
59
|
-
if s.respond_to? :specification_version then
|
60
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
61
|
-
s.specification_version = 3
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
62
17
|
|
63
|
-
|
64
|
-
|
65
|
-
s.add_runtime_dependency(%q<httparty>, [">= 0"])
|
66
|
-
s.add_development_dependency(%q<webmock>, [">= 1.6.1"])
|
67
|
-
else
|
68
|
-
s.add_dependency(%q<riot>, [">= 0"])
|
69
|
-
s.add_dependency(%q<httparty>, [">= 0"])
|
70
|
-
s.add_dependency(%q<webmock>, [">= 1.6.1"])
|
71
|
-
end
|
72
|
-
else
|
73
|
-
s.add_dependency(%q<riot>, [">= 0"])
|
74
|
-
s.add_dependency(%q<httparty>, [">= 0"])
|
75
|
-
s.add_dependency(%q<webmock>, [">= 1.6.1"])
|
76
|
-
end
|
18
|
+
s.add_dependency 'riot', '>=0.12.5'
|
19
|
+
s.add_dependency 'httparty', '>=0.6.0'
|
77
20
|
end
|
78
21
|
|
data/test/actions/delete_test.rb
CHANGED
@@ -1,48 +1,57 @@
|
|
1
1
|
require 'teststrap'
|
2
2
|
|
3
|
-
context "Sending a DELETE request" do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
3
|
+
context "Sending a DELETE request with a base uri" do
|
4
|
+
|
5
|
+
context "without params" do
|
6
|
+
hookup do
|
7
|
+
stub_request(:delete, 'http://test.local/foo').with(:body => {"foo" => "bar"}.to_json).
|
8
|
+
to_return(:body => "Foo", :status => 200)
|
9
|
+
end
|
10
|
+
|
11
|
+
base_uri "http://test.local"
|
12
|
+
delete "/foo", :body => {"foo" => "bar"}.to_json
|
13
|
+
|
14
|
+
asserts("status code") { response.code }.equals(200)
|
15
|
+
asserts("response body") { response.body }.equals("Foo")
|
16
|
+
end # without params
|
17
|
+
|
18
|
+
context "with params" do
|
19
|
+
hookup do
|
20
|
+
stub_request(:delete, 'http://test.local/foo?bar=baz').
|
21
|
+
with(:body => {"goo" => "car"}.to_json).
|
22
|
+
to_return(:body => "", :status => 203)
|
23
|
+
end
|
24
|
+
|
25
|
+
context "through default_params" do
|
26
|
+
base_uri "http://test.local"
|
27
|
+
default_params({"bar" => "baz"})
|
28
|
+
delete "/foo", :body => {"goo" => "car"}.to_json
|
29
|
+
|
30
|
+
asserts("status code") { response.code }.equals(203)
|
31
|
+
end # through default_params
|
32
|
+
|
33
|
+
context "through query string" do
|
17
34
|
base_uri "http://test.local"
|
18
|
-
delete "/foo", :body => {"
|
19
|
-
|
20
|
-
asserts("status code") { response.code }.equals(
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
delete "/foo?bar=baz", :body => {"goo" => "car"}.to_json
|
42
|
-
|
43
|
-
asserts("status code") { response.code }.equals(203)
|
44
|
-
end # through query string
|
45
|
-
end # with params
|
46
|
-
end # with a base-uri
|
47
|
-
|
48
|
-
end # Sending a DELETE request
|
35
|
+
delete "/foo?bar=baz", :body => {"goo" => "car"}.to_json
|
36
|
+
|
37
|
+
asserts("status code") { response.code }.equals(203)
|
38
|
+
end # through query string
|
39
|
+
end # with params
|
40
|
+
|
41
|
+
context "while processing options from a block" do
|
42
|
+
hookup do
|
43
|
+
stub_request(:delete, 'http://test.local/foo/bar').
|
44
|
+
with(:body => {"s" => "things"}.to_json).
|
45
|
+
to_return(:body => "", :status => 299)
|
46
|
+
end
|
47
|
+
|
48
|
+
base_uri "http://test.local"
|
49
|
+
|
50
|
+
delete do
|
51
|
+
{ :path => "/foo/bar", :body => {"s" => "things"}.to_json }
|
52
|
+
end
|
53
|
+
|
54
|
+
asserts("status code") { response.code }.equals(299)
|
55
|
+
end # while processing options from a block
|
56
|
+
|
57
|
+
end # Sending a DELETE request with a base uri
|
data/test/actions/get_test.rb
CHANGED
@@ -1,43 +1,102 @@
|
|
1
1
|
require 'teststrap'
|
2
2
|
|
3
|
-
context "Sending a GET request" do
|
4
|
-
# teardown { reset_webmock }
|
3
|
+
context "Sending a GET request with a base-uri" do
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
context "without params" do
|
6
|
+
hookup do
|
7
|
+
stub_request(:get, 'http://test.local/foo').to_return(:body => "Foo", :status => 200)
|
8
|
+
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
hookup do
|
13
|
-
stub_request(:get, 'http://test.local/foo').to_return(:body => "Foo", :status => 200)
|
14
|
-
end
|
10
|
+
base_uri "http://test.local"
|
11
|
+
get "/foo"
|
15
12
|
|
13
|
+
asserts("status code") { response.code }.equals(200)
|
14
|
+
asserts("response body") { response.body }.equals("Foo")
|
15
|
+
end # without params
|
16
|
+
|
17
|
+
context "with params" do
|
18
|
+
hookup { stub_request(:get, 'http://test.local/foo?bar=baz').to_return(:body => "", :status => 201) }
|
19
|
+
|
20
|
+
context "through default_params" do
|
16
21
|
base_uri "http://test.local"
|
22
|
+
default_params({"bar" => "baz"})
|
17
23
|
get "/foo"
|
18
|
-
|
19
|
-
asserts("status code") { response.code }.equals(
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
24
|
+
|
25
|
+
asserts("status code") { response.code }.equals(201)
|
26
|
+
end # through default_params
|
27
|
+
|
28
|
+
context "through query string" do
|
29
|
+
base_uri "http://test.local"
|
30
|
+
get "/foo?bar=baz"
|
31
|
+
|
32
|
+
asserts("status code") { response.code }.equals(201)
|
33
|
+
end # through query string
|
34
|
+
end # with params
|
35
|
+
|
36
|
+
context "while processing options from a block" do
|
37
|
+
hookup do
|
38
|
+
stub_request(:get, 'http://test.local/foo/bar?s=things').to_return(:body => "", :status => 299)
|
39
|
+
end
|
40
|
+
|
41
|
+
base_uri "http://test.local"
|
42
|
+
|
43
|
+
get do
|
44
|
+
{ :path => "/foo/bar", :query => {"s" => "things"} }
|
45
|
+
end
|
46
|
+
|
47
|
+
asserts("status code") { response.code }.equals(299)
|
48
|
+
end # while processing options from a block
|
49
|
+
|
50
|
+
context "when no path provided from block" do
|
51
|
+
hookup do
|
52
|
+
stub_request(:get, 'http://test.local/?s=things').to_return(:body => "", :status => 299)
|
53
|
+
end
|
54
|
+
|
55
|
+
base_uri "http://test.local"
|
56
|
+
|
57
|
+
get do # should default path to just "/"
|
58
|
+
{ :query => {"s" => "things"} }
|
59
|
+
end
|
60
|
+
|
61
|
+
asserts("status code") { response.code }.equals(299)
|
62
|
+
end # while processing options from a block
|
63
|
+
|
64
|
+
context "allows response sharing" do
|
65
|
+
hookup do
|
66
|
+
stub_request(:get, 'http://test.local/things/1').
|
67
|
+
to_return({
|
68
|
+
:status => 200,
|
69
|
+
:headers => { "Content-Type" => "application/json" },
|
70
|
+
:body => {id: 1, name: "Shakes"}.to_json
|
71
|
+
})
|
72
|
+
stub_request(:get, 'http://test.local/things/2').
|
73
|
+
to_return({
|
74
|
+
:status => 200,
|
75
|
+
:headers => { "Content-Type" => "application/json" },
|
76
|
+
:body => {id: 2, name: "Stakes"}.to_json
|
77
|
+
})
|
78
|
+
stub_request(:get, 'http://test.local/search?s=Shakes,Stakes').
|
79
|
+
to_return(:body => "some kind of response", :status => 200)
|
80
|
+
end
|
81
|
+
|
82
|
+
base_uri "http://test.local"
|
83
|
+
|
84
|
+
get(:thing_1) do
|
85
|
+
{ :path => "/things/1" }
|
86
|
+
end
|
87
|
+
|
88
|
+
get(:thing_2) do
|
89
|
+
{ :path => "/things/2" }
|
90
|
+
end
|
91
|
+
|
92
|
+
get do
|
93
|
+
{ :path => "/search",
|
94
|
+
:query => { "s" => [ response(:thing_1)["name"], response(:thing_2)["name"] ].join(",") }
|
95
|
+
}
|
96
|
+
end
|
97
|
+
|
98
|
+
asserts("status code") { response.code }.equals(200)
|
99
|
+
asserts("body") { response.body }.equals("some kind of response")
|
100
|
+
end # while processing options from a block
|
101
|
+
|
102
|
+
end # Sending a GET request with a base-uri
|
data/test/actions/post_test.rb
CHANGED
@@ -1,48 +1,58 @@
|
|
1
1
|
require 'teststrap'
|
2
2
|
|
3
|
-
context "Sending a POST request" do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
3
|
+
context "Sending a POST request with a base uri" do
|
4
|
+
|
5
|
+
context "without params" do
|
6
|
+
hookup do
|
7
|
+
stub_request(:post, 'http://test.local/foo').
|
8
|
+
with(:body => {"foo" => "bar"}.to_json).
|
9
|
+
to_return(:body => "Foo", :status => 200)
|
10
|
+
end
|
11
|
+
|
12
|
+
base_uri "http://test.local"
|
13
|
+
post "/foo", :body => {"foo" => "bar"}.to_json
|
14
|
+
|
15
|
+
asserts("status code") { response.code }.equals(200)
|
16
|
+
asserts("response body") { response.body }.equals("Foo")
|
17
|
+
end # without params
|
18
|
+
|
19
|
+
context "with params" do
|
20
|
+
hookup do
|
21
|
+
stub_request(:post, 'http://test.local/foo?bar=baz').
|
22
|
+
with(:body => {"goo" => "car"}.to_json).
|
23
|
+
to_return(:body => "", :status => 201)
|
24
|
+
end
|
25
|
+
|
26
|
+
context "through default_params" do
|
27
|
+
base_uri "http://test.local"
|
28
|
+
default_params({"bar" => "baz"})
|
29
|
+
post "/foo", :body => {"goo" => "car"}.to_json
|
30
|
+
|
31
|
+
asserts("status code") { response.code }.equals(201)
|
32
|
+
end # through default_params
|
33
|
+
|
34
|
+
context "through query string" do
|
17
35
|
base_uri "http://test.local"
|
18
|
-
post "/foo", :body => {"
|
19
|
-
|
20
|
-
asserts("status code") { response.code }.equals(
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
post "/foo?bar=baz", :body => {"goo" => "car"}.to_json
|
42
|
-
|
43
|
-
asserts("status code") { response.code }.equals(201)
|
44
|
-
end # through query string
|
45
|
-
end # with params
|
46
|
-
end # with a base-uri
|
47
|
-
|
48
|
-
end # Sending a POST request
|
36
|
+
post "/foo?bar=baz", :body => {"goo" => "car"}.to_json
|
37
|
+
|
38
|
+
asserts("status code") { response.code }.equals(201)
|
39
|
+
end # through query string
|
40
|
+
end # with params
|
41
|
+
|
42
|
+
context "while processing options from a block" do
|
43
|
+
hookup do
|
44
|
+
stub_request(:post, 'http://test.local/foo/bar').
|
45
|
+
with(:body => {"s" => "things"}.to_json).
|
46
|
+
to_return(:body => "", :status => 299)
|
47
|
+
end
|
48
|
+
|
49
|
+
base_uri "http://test.local"
|
50
|
+
|
51
|
+
post do
|
52
|
+
{ :path => "/foo/bar", :body => {"s" => "things"}.to_json }
|
53
|
+
end
|
54
|
+
|
55
|
+
asserts("status code") { response.code }.equals(299)
|
56
|
+
end # while processing options from a block
|
57
|
+
|
58
|
+
end # Sending a POST request with a base uri
|
data/test/actions/put_test.rb
CHANGED
@@ -1,48 +1,57 @@
|
|
1
1
|
require 'teststrap'
|
2
2
|
|
3
|
-
context "Sending a PUT request" do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
3
|
+
context "Sending a PUT request with a base uri" do
|
4
|
+
|
5
|
+
context "without params" do
|
6
|
+
hookup do
|
7
|
+
stub_request(:put, 'http://test.local/foo').with(:body => {"foo" => "bar"}.to_json).
|
8
|
+
to_return(:body => "Foo", :status => 200)
|
9
|
+
end
|
10
|
+
|
11
|
+
base_uri "http://test.local"
|
12
|
+
put "/foo", :body => {"foo" => "bar"}.to_json
|
13
|
+
|
14
|
+
asserts("status code") { response.code }.equals(200)
|
15
|
+
asserts("response body") { response.body }.equals("Foo")
|
16
|
+
end # without params
|
17
|
+
|
18
|
+
context "with params" do
|
19
|
+
hookup do
|
20
|
+
stub_request(:put, 'http://test.local/foo?bar=baz').
|
21
|
+
with(:body => {"goo" => "car"}.to_json).
|
22
|
+
to_return(:body => "", :status => 203)
|
23
|
+
end
|
24
|
+
|
25
|
+
context "through default_params" do
|
26
|
+
base_uri "http://test.local"
|
27
|
+
default_params({"bar" => "baz"})
|
28
|
+
put "/foo", :body => {"goo" => "car"}.to_json
|
29
|
+
|
30
|
+
asserts("status code") { response.code }.equals(203)
|
31
|
+
end # through default_params
|
32
|
+
|
33
|
+
context "through query string" do
|
17
34
|
base_uri "http://test.local"
|
18
|
-
put "/foo", :body => {"
|
19
|
-
|
20
|
-
asserts("status code") { response.code }.equals(
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
put "/foo?bar=baz", :body => {"goo" => "car"}.to_json
|
42
|
-
|
43
|
-
asserts("status code") { response.code }.equals(203)
|
44
|
-
end # through query string
|
45
|
-
end # with params
|
46
|
-
end # with a base-uri
|
47
|
-
|
48
|
-
end # Sending a PUT request
|
35
|
+
put "/foo?bar=baz", :body => {"goo" => "car"}.to_json
|
36
|
+
|
37
|
+
asserts("status code") { response.code }.equals(203)
|
38
|
+
end # through query string
|
39
|
+
end # with params
|
40
|
+
|
41
|
+
context "while processing options from a block" do
|
42
|
+
hookup do
|
43
|
+
stub_request(:put, 'http://test.local/foo/bar').
|
44
|
+
with(:body => {"s" => "things"}.to_json).
|
45
|
+
to_return(:body => "", :status => 299)
|
46
|
+
end
|
47
|
+
|
48
|
+
base_uri "http://test.local"
|
49
|
+
|
50
|
+
put do
|
51
|
+
{ :path => "/foo/bar", :body => {"s" => "things"}.to_json }
|
52
|
+
end
|
53
|
+
|
54
|
+
asserts("status code") { response.code }.equals(299)
|
55
|
+
end # while processing options from a block
|
56
|
+
|
57
|
+
end # Sending a PUT request with a base uri
|