riot-gear 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/riot/gear/context/{http.rb → persist_cookie.rb} +5 -9
- data/lib/riot/gear/middleware/riotparty.rb +27 -12
- data/riot-gear.gemspec +10 -4
- data/test/actions/delete_test.rb +48 -0
- data/test/actions/get_test.rb +14 -18
- data/test/actions/post_test.rb +48 -0
- data/test/actions/put_test.rb +48 -0
- data/test/teststrap.rb +1 -0
- metadata +11 -5
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
@@ -3,12 +3,7 @@ require 'httparty'
|
|
3
3
|
|
4
4
|
module Riot
|
5
5
|
module Gear
|
6
|
-
module
|
7
|
-
|
8
|
-
# Setup the scenario via a GET requst to the provided path. Feel free to include a query string
|
9
|
-
def get(*args)
|
10
|
-
hookup { @smoke_response = topic.get(*args) }
|
11
|
-
end
|
6
|
+
module PersistCookie
|
12
7
|
|
13
8
|
def persist_cookie(cookie_name)
|
14
9
|
hookup do
|
@@ -16,9 +11,10 @@ module Riot
|
|
16
11
|
topic.cookies({cookie_name => cookie_value["value"]})
|
17
12
|
end
|
18
13
|
end
|
19
|
-
end
|
20
|
-
|
14
|
+
end # persist_cookie
|
15
|
+
|
16
|
+
end # PersistCookie
|
21
17
|
end # Gear
|
22
18
|
end # Riot
|
23
19
|
|
24
|
-
Riot::Context.instance_eval { include Riot::Gear::
|
20
|
+
Riot::Context.instance_eval { include Riot::Gear::PersistCookie }
|
@@ -8,6 +8,7 @@ module Riot
|
|
8
8
|
def call(context)
|
9
9
|
setup_faux_class(context)
|
10
10
|
setup_helpers(context)
|
11
|
+
proxy_action_methods(context)
|
11
12
|
proxy_httparty_hookups(context)
|
12
13
|
middleware.call(context)
|
13
14
|
end
|
@@ -27,26 +28,40 @@ module Riot
|
|
27
28
|
context.helper(:response) { @smoke_response }
|
28
29
|
end # setup_faux_class
|
29
30
|
|
30
|
-
|
31
|
-
|
31
|
+
#
|
32
|
+
# Method proxying. This is the meat of the DSL.
|
33
|
+
|
34
|
+
def actionable_methods; [:get, :post, :put, :delete, :head]; end
|
35
|
+
|
36
|
+
def proxy_action_methods(context)
|
37
|
+
proxy_class_methods_to_context(context, actionable_methods) do |situation, result|
|
38
|
+
situation.instance_eval { @smoke_response = result }
|
39
|
+
end
|
32
40
|
end
|
33
41
|
|
34
|
-
def
|
42
|
+
def proxiable_methods
|
35
43
|
methods = HTTParty::ClassMethods.instance_methods.map { |m| m.to_s.to_sym }
|
36
|
-
methods -
|
44
|
+
methods - actionable_methods - [:options, :default_options]
|
37
45
|
end
|
38
46
|
|
39
|
-
# Basically, we're just passing standard HTTParty setup methods onto situation via hookups. Except
|
40
|
-
# for the important action methods.
|
41
47
|
def proxy_httparty_hookups(context)
|
42
|
-
|
43
|
-
|
48
|
+
proxy_class_methods_to_context(context, proxiable_methods)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Basically, we're just passing standard HTTParty setup methods onto situation via hookups
|
52
|
+
def proxy_class_methods_to_context(context, methods, &proxy_block)
|
53
|
+
methods.each do |method_name|
|
54
|
+
(class << context; self; end).__send__(:define_method, method_name) do |*args|
|
44
55
|
hookup do
|
45
|
-
topic.__send__(
|
56
|
+
result = topic.__send__(method_name, *args)
|
57
|
+
yield(self, result) if proxy_block
|
46
58
|
end
|
47
|
-
end
|
48
|
-
end #
|
49
|
-
end #
|
59
|
+
end # class << context
|
60
|
+
end # methods.each
|
61
|
+
end # proxy_class_methods_to_context
|
62
|
+
|
63
|
+
#
|
64
|
+
# Helpful helpers
|
50
65
|
|
51
66
|
def setup_helpers(context)
|
52
67
|
helper_json_path(context)
|
data/riot-gear.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{riot-gear}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Justin 'Gus' Knowlden"]
|
12
|
-
s.date = %q{2010-07-
|
12
|
+
s.date = %q{2010-07-09}
|
13
13
|
s.description = %q{Riot + HTTParty smoke testing framework. You'd use it for integration testing with real HTTP requests and responses}
|
14
14
|
s.email = %q{gus@gusg.us}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -25,11 +25,14 @@ Gem::Specification.new do |s|
|
|
25
25
|
"lib/riot/gear/context/asserts_header.rb",
|
26
26
|
"lib/riot/gear/context/asserts_json.rb",
|
27
27
|
"lib/riot/gear/context/asserts_status.rb",
|
28
|
-
"lib/riot/gear/context/
|
28
|
+
"lib/riot/gear/context/persist_cookie.rb",
|
29
29
|
"lib/riot/gear/middleware.rb",
|
30
30
|
"lib/riot/gear/middleware/riotparty.rb",
|
31
31
|
"riot-gear.gemspec",
|
32
|
+
"test/actions/delete_test.rb",
|
32
33
|
"test/actions/get_test.rb",
|
34
|
+
"test/actions/post_test.rb",
|
35
|
+
"test/actions/put_test.rb",
|
33
36
|
"test/helpers/cookie_values_test.rb",
|
34
37
|
"test/helpers/json_path_test.rb",
|
35
38
|
"test/riotparty_proxy_methods_test.rb",
|
@@ -42,7 +45,10 @@ Gem::Specification.new do |s|
|
|
42
45
|
s.rubygems_version = %q{1.3.7}
|
43
46
|
s.summary = %q{Riot + HTTParty smoke testing framework}
|
44
47
|
s.test_files = [
|
45
|
-
"test/actions/
|
48
|
+
"test/actions/delete_test.rb",
|
49
|
+
"test/actions/get_test.rb",
|
50
|
+
"test/actions/post_test.rb",
|
51
|
+
"test/actions/put_test.rb",
|
46
52
|
"test/helpers/cookie_values_test.rb",
|
47
53
|
"test/helpers/json_path_test.rb",
|
48
54
|
"test/riotparty_proxy_methods_test.rb",
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'teststrap'
|
2
|
+
|
3
|
+
context "Sending a DELETE request" do
|
4
|
+
teardown { reset_webmock }
|
5
|
+
|
6
|
+
asserts("not defining a base_uri") do
|
7
|
+
Riot::Context.new("foo") { delete "/foo" }.run(Riot::SilentReporter.new)
|
8
|
+
end.raises(HTTParty::UnsupportedURIScheme)
|
9
|
+
|
10
|
+
context "with a base-uri" do
|
11
|
+
context "without params" do
|
12
|
+
hookup do
|
13
|
+
stub_request(:delete, 'http://test.local/foo').with(:body => {"foo" => "bar"}.to_json).
|
14
|
+
to_return(:body => "Foo", :status => 200)
|
15
|
+
end
|
16
|
+
|
17
|
+
base_uri "http://test.local"
|
18
|
+
delete "/foo", :body => {"foo" => "bar"}.to_json
|
19
|
+
|
20
|
+
asserts("status code") { response.code }.equals(200)
|
21
|
+
asserts("response body") { response.body }.equals("Foo")
|
22
|
+
end # without params
|
23
|
+
|
24
|
+
context "with params" do
|
25
|
+
hookup do
|
26
|
+
stub_request(:delete, 'http://test.local/foo?bar=baz').
|
27
|
+
with(:body => {"goo" => "car"}.to_json).
|
28
|
+
to_return(:body => "", :status => 203)
|
29
|
+
end
|
30
|
+
|
31
|
+
context "through default_params" do
|
32
|
+
base_uri "http://test.local"
|
33
|
+
default_params({"bar" => "baz"})
|
34
|
+
delete "/foo", :body => {"goo" => "car"}.to_json
|
35
|
+
|
36
|
+
asserts("status code") { response.code }.equals(203)
|
37
|
+
end # through default_params
|
38
|
+
|
39
|
+
context "through query string" do
|
40
|
+
base_uri "http://test.local"
|
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
|
data/test/actions/get_test.rb
CHANGED
@@ -20,28 +20,24 @@ context "Sending a GET request" do
|
|
20
20
|
asserts("response body") { response.body }.equals("Foo")
|
21
21
|
end # without params
|
22
22
|
|
23
|
-
context "with
|
24
|
-
hookup
|
25
|
-
stub_request(:get, 'http://test.local/foo?bar=baz').to_return(:body => "", :status => 201)
|
26
|
-
end
|
23
|
+
context "with params" do
|
24
|
+
hookup { stub_request(:get, 'http://test.local/foo?bar=baz').to_return(:body => "", :status => 201) }
|
27
25
|
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
context "through default_params" do
|
27
|
+
base_uri "http://test.local"
|
28
|
+
default_params({"bar" => "baz"})
|
29
|
+
get "/foo"
|
31
30
|
|
32
|
-
|
33
|
-
|
31
|
+
asserts("status code") { response.code }.equals(201)
|
32
|
+
end # through default_params
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
base_uri "http://test.local"
|
41
|
-
get "/foo?bar=baz"
|
34
|
+
context "through query string" do
|
35
|
+
base_uri "http://test.local"
|
36
|
+
get "/foo?bar=baz"
|
42
37
|
|
43
|
-
|
44
|
-
|
38
|
+
asserts("status code") { response.code }.equals(201)
|
39
|
+
end # through query string
|
40
|
+
end # with params
|
45
41
|
end # with a base-uri
|
46
42
|
|
47
43
|
end # Sending a GET request
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'teststrap'
|
2
|
+
|
3
|
+
context "Sending a POST request" do
|
4
|
+
teardown { reset_webmock }
|
5
|
+
|
6
|
+
asserts("not defining a base_uri") do
|
7
|
+
Riot::Context.new("foo") { post "/foo" }.run(Riot::SilentReporter.new)
|
8
|
+
end.raises(HTTParty::UnsupportedURIScheme)
|
9
|
+
|
10
|
+
context "with a base-uri" do
|
11
|
+
context "without params" do
|
12
|
+
hookup do
|
13
|
+
stub_request(:post, 'http://test.local/foo').with(:body => {"foo" => "bar"}.to_json).
|
14
|
+
to_return(:body => "Foo", :status => 200)
|
15
|
+
end
|
16
|
+
|
17
|
+
base_uri "http://test.local"
|
18
|
+
post "/foo", :body => {"foo" => "bar"}.to_json
|
19
|
+
|
20
|
+
asserts("status code") { response.code }.equals(200)
|
21
|
+
asserts("response body") { response.body }.equals("Foo")
|
22
|
+
end # without params
|
23
|
+
|
24
|
+
context "with params" do
|
25
|
+
hookup do
|
26
|
+
stub_request(:post, 'http://test.local/foo?bar=baz').
|
27
|
+
with(:body => {"goo" => "car"}.to_json).
|
28
|
+
to_return(:body => "", :status => 201)
|
29
|
+
end
|
30
|
+
|
31
|
+
context "through default_params" do
|
32
|
+
base_uri "http://test.local"
|
33
|
+
default_params({"bar" => "baz"})
|
34
|
+
post "/foo", :body => {"goo" => "car"}.to_json
|
35
|
+
|
36
|
+
asserts("status code") { response.code }.equals(201)
|
37
|
+
end # through default_params
|
38
|
+
|
39
|
+
context "through query string" do
|
40
|
+
base_uri "http://test.local"
|
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
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'teststrap'
|
2
|
+
|
3
|
+
context "Sending a PUT request" do
|
4
|
+
teardown { reset_webmock }
|
5
|
+
|
6
|
+
asserts("not defining a base_uri") do
|
7
|
+
Riot::Context.new("foo") { put "/foo" }.run(Riot::SilentReporter.new)
|
8
|
+
end.raises(HTTParty::UnsupportedURIScheme)
|
9
|
+
|
10
|
+
context "with a base-uri" do
|
11
|
+
context "without params" do
|
12
|
+
hookup do
|
13
|
+
stub_request(:put, 'http://test.local/foo').with(:body => {"foo" => "bar"}.to_json).
|
14
|
+
to_return(:body => "Foo", :status => 200)
|
15
|
+
end
|
16
|
+
|
17
|
+
base_uri "http://test.local"
|
18
|
+
put "/foo", :body => {"foo" => "bar"}.to_json
|
19
|
+
|
20
|
+
asserts("status code") { response.code }.equals(200)
|
21
|
+
asserts("response body") { response.body }.equals("Foo")
|
22
|
+
end # without params
|
23
|
+
|
24
|
+
context "with params" do
|
25
|
+
hookup do
|
26
|
+
stub_request(:put, 'http://test.local/foo?bar=baz').
|
27
|
+
with(:body => {"goo" => "car"}.to_json).
|
28
|
+
to_return(:body => "", :status => 203)
|
29
|
+
end
|
30
|
+
|
31
|
+
context "through default_params" do
|
32
|
+
base_uri "http://test.local"
|
33
|
+
default_params({"bar" => "baz"})
|
34
|
+
put "/foo", :body => {"goo" => "car"}.to_json
|
35
|
+
|
36
|
+
asserts("status code") { response.code }.equals(203)
|
37
|
+
end # through default_params
|
38
|
+
|
39
|
+
context "through query string" do
|
40
|
+
base_uri "http://test.local"
|
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
|
data/test/teststrap.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riot-gear
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 6
|
10
|
+
version: 0.0.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Justin 'Gus' Knowlden
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-07-
|
18
|
+
date: 2010-07-09 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -78,11 +78,14 @@ files:
|
|
78
78
|
- lib/riot/gear/context/asserts_header.rb
|
79
79
|
- lib/riot/gear/context/asserts_json.rb
|
80
80
|
- lib/riot/gear/context/asserts_status.rb
|
81
|
-
- lib/riot/gear/context/
|
81
|
+
- lib/riot/gear/context/persist_cookie.rb
|
82
82
|
- lib/riot/gear/middleware.rb
|
83
83
|
- lib/riot/gear/middleware/riotparty.rb
|
84
84
|
- riot-gear.gemspec
|
85
|
+
- test/actions/delete_test.rb
|
85
86
|
- test/actions/get_test.rb
|
87
|
+
- test/actions/post_test.rb
|
88
|
+
- test/actions/put_test.rb
|
86
89
|
- test/helpers/cookie_values_test.rb
|
87
90
|
- test/helpers/json_path_test.rb
|
88
91
|
- test/riotparty_proxy_methods_test.rb
|
@@ -123,7 +126,10 @@ signing_key:
|
|
123
126
|
specification_version: 3
|
124
127
|
summary: Riot + HTTParty smoke testing framework
|
125
128
|
test_files:
|
129
|
+
- test/actions/delete_test.rb
|
126
130
|
- test/actions/get_test.rb
|
131
|
+
- test/actions/post_test.rb
|
132
|
+
- test/actions/put_test.rb
|
127
133
|
- test/helpers/cookie_values_test.rb
|
128
134
|
- test/helpers/json_path_test.rb
|
129
135
|
- test/riotparty_proxy_methods_test.rb
|