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.
@@ -0,0 +1,6 @@
1
+ module Riot
2
+ module Gear
3
+ VERSION = "0.0.9"
4
+ end
5
+ end
6
+
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 = %q{riot-gear}
8
- s.version = "0.0.8"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Justin 'Gus' Knowlden"]
12
- s.date = %q{2010-12-23}
13
- s.description = %q{Riot + HTTParty smoke testing framework. You'd use it for integration testing with real HTTP requests and responses}
14
- s.email = %q{gus@gusg.us}
15
- s.extra_rdoc_files = [
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.rubygems_version = %q{1.3.7}
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
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
64
- s.add_runtime_dependency(%q<riot>, [">= 0"])
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
 
@@ -1,48 +1,57 @@
1
1
  require 'teststrap'
2
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
-
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 => {"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
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
@@ -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
- asserts("not defining a base_uri") do
7
- Riot::Context.new("foo") { get "/foo" }.run(Riot::SilentReporter.new)
8
- end.raises(HTTParty::UnsupportedURIScheme)
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
- context "with a base-uri" do
11
- context "without params" do
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(200)
20
- asserts("response body") { response.body }.equals("Foo")
21
- end # without params
22
-
23
- context "with params" do
24
- hookup { stub_request(:get, 'http://test.local/foo?bar=baz').to_return(:body => "", :status => 201) }
25
-
26
- context "through default_params" do
27
- base_uri "http://test.local"
28
- default_params({"bar" => "baz"})
29
- get "/foo"
30
-
31
- asserts("status code") { response.code }.equals(201)
32
- end # through default_params
33
-
34
- context "through query string" do
35
- base_uri "http://test.local"
36
- get "/foo?bar=baz"
37
-
38
- asserts("status code") { response.code }.equals(201)
39
- end # through query string
40
- end # with params
41
- end # with a base-uri
42
-
43
- end # Sending a GET request
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
@@ -1,48 +1,58 @@
1
1
  require 'teststrap'
2
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
-
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 => {"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
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
@@ -1,48 +1,57 @@
1
1
  require 'teststrap'
2
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
-
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 => {"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
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