riot-gear 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -40,7 +40,7 @@ begin
40
40
  gem.authors = ["Justin 'Gus' Knowlden"]
41
41
  gem.add_dependency 'riot'
42
42
  gem.add_dependency 'httparty'
43
- gem.add_development_dependency 'webmock'
43
+ gem.add_development_dependency 'webmock', ">=1.6.1"
44
44
  end
45
45
  Jeweler::GemcutterTasks.new
46
46
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.7
1
+ 0.0.8
@@ -4,11 +4,22 @@ module Riot
4
4
  module Gear
5
5
  module AssertsJson
6
6
 
7
- def asserts_json(json_path)
8
- asserts("value from body as json:#{json_path}") do
9
- json_path(response, json_path)
7
+ # Returns the value of passing the JSON path to the json_path helper. If a handler block is provided,
8
+ # that block will be called with the value and the response from the block will be used as the actual
9
+ # in the assertion test.
10
+ #
11
+ # asserts_json("http.status_code").equals(200)
12
+ #
13
+ # asserts_json("http") do |value|
14
+ # value["status_code"]
15
+ # end.equals(200)
16
+ def asserts_json(json_string, &handler)
17
+ asserts("value from body as json:#{json_string}") do
18
+ value = json_path(response, json_string)
19
+ handler ? handler.call(value) : value
10
20
  end
11
21
  end
22
+
12
23
  end # AssertsJson
13
24
  end # Gear
14
25
  end # Riot
data/riot-gear.gemspec CHANGED
@@ -1,59 +1,59 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{riot-gear}
8
- s.version = "0.0.7"
8
+ s.version = "0.0.8"
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}
12
+ s.date = %q{2010-12-23}
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 = [
16
16
  "README.md"
17
17
  ]
18
18
  s.files = [
19
- ".gitignore",
20
- "README.md",
21
- "Rakefile",
22
- "VERSION",
23
- "lib/riot/gear.rb",
24
- "lib/riot/gear/context.rb",
25
- "lib/riot/gear/context/asserts_header.rb",
26
- "lib/riot/gear/context/asserts_json.rb",
27
- "lib/riot/gear/context/asserts_status.rb",
28
- "lib/riot/gear/context/persist_cookie.rb",
29
- "lib/riot/gear/middleware.rb",
30
- "lib/riot/gear/middleware/riotparty.rb",
31
- "riot-gear.gemspec",
32
- "test/actions/delete_test.rb",
33
- "test/actions/get_test.rb",
34
- "test/actions/post_test.rb",
35
- "test/actions/put_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"
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
41
  ]
42
42
  s.homepage = %q{http://github.com/thumblemonks/riot-gear}
43
- s.rdoc_options = ["--charset=UTF-8"]
44
43
  s.require_paths = ["lib"]
45
44
  s.rubygems_version = %q{1.3.7}
46
45
  s.summary = %q{Riot + HTTParty smoke testing framework}
47
46
  s.test_files = [
48
47
  "test/actions/delete_test.rb",
49
- "test/actions/get_test.rb",
50
- "test/actions/post_test.rb",
51
- "test/actions/put_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"
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
57
  ]
58
58
 
59
59
  if s.respond_to? :specification_version then
@@ -63,16 +63,16 @@ Gem::Specification.new do |s|
63
63
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
64
64
  s.add_runtime_dependency(%q<riot>, [">= 0"])
65
65
  s.add_runtime_dependency(%q<httparty>, [">= 0"])
66
- s.add_development_dependency(%q<webmock>, [">= 0"])
66
+ s.add_development_dependency(%q<webmock>, [">= 1.6.1"])
67
67
  else
68
68
  s.add_dependency(%q<riot>, [">= 0"])
69
69
  s.add_dependency(%q<httparty>, [">= 0"])
70
- s.add_dependency(%q<webmock>, [">= 0"])
70
+ s.add_dependency(%q<webmock>, [">= 1.6.1"])
71
71
  end
72
72
  else
73
73
  s.add_dependency(%q<riot>, [">= 0"])
74
74
  s.add_dependency(%q<httparty>, [">= 0"])
75
- s.add_dependency(%q<webmock>, [">= 0"])
75
+ s.add_dependency(%q<webmock>, [">= 1.6.1"])
76
76
  end
77
77
  end
78
78
 
@@ -1,7 +1,7 @@
1
1
  require 'teststrap'
2
2
 
3
3
  context "Sending a DELETE request" do
4
- teardown { reset_webmock }
4
+ # teardown { reset_webmock }
5
5
 
6
6
  asserts("not defining a base_uri") do
7
7
  Riot::Context.new("foo") { delete "/foo" }.run(Riot::SilentReporter.new)
@@ -1,7 +1,7 @@
1
1
  require 'teststrap'
2
2
 
3
3
  context "Sending a GET request" do
4
- teardown { reset_webmock }
4
+ # teardown { reset_webmock }
5
5
 
6
6
  asserts("not defining a base_uri") do
7
7
  Riot::Context.new("foo") { get "/foo" }.run(Riot::SilentReporter.new)
@@ -1,7 +1,7 @@
1
1
  require 'teststrap'
2
2
 
3
3
  context "Sending a POST request" do
4
- teardown { reset_webmock }
4
+ # teardown { reset_webmock }
5
5
 
6
6
  asserts("not defining a base_uri") do
7
7
  Riot::Context.new("foo") { post "/foo" }.run(Riot::SilentReporter.new)
@@ -1,7 +1,7 @@
1
1
  require 'teststrap'
2
2
 
3
3
  context "Sending a PUT request" do
4
- teardown { reset_webmock }
4
+ # teardown { reset_webmock }
5
5
 
6
6
  asserts("not defining a base_uri") do
7
7
  Riot::Context.new("foo") { put "/foo" }.run(Riot::SilentReporter.new)
@@ -0,0 +1,18 @@
1
+ require 'teststrap'
2
+
3
+ context "The asserts_json macro" do
4
+
5
+ helper(:response) do
6
+ {
7
+ "a" => {"b" => "foo"},
8
+ "c" => [["foo", 1], ["bar", 2]]
9
+ }
10
+ end
11
+
12
+ asserts_json("a.b").equals("foo")
13
+
14
+ asserts_json("c") do |value|
15
+ value.map { |string, number| number }
16
+ end.equals([1,2])
17
+
18
+ end # The asserts_json macro
@@ -56,4 +56,15 @@ context "The json_path helper" do
56
56
  json_path({"a" => [ {"b" => "nil"}, {"c" => ["foo", "bar"]} ]}, '[a][1].c[0]')
57
57
  end.equals("foo")
58
58
  end # for mix of hash and index based-lookups
59
+
60
+ context "when response is an array" do
61
+ asserts("path of existing '[1]'") do
62
+ json_path(["foo", "bar"], '[1]')
63
+ end.equals("bar")
64
+
65
+ asserts("path of existing '[1].zoot[a]'") do
66
+ json_path(["foo", {"zoot" => {"a" => "bar"}}], '[1].zoot[a]')
67
+ end.equals("bar")
68
+ end # when response is an array
69
+
59
70
  end # The json_path helper
data/test/teststrap.rb CHANGED
@@ -6,7 +6,8 @@ require 'rubygems'
6
6
  require 'json'
7
7
  require 'riot'
8
8
  require 'webmock'
9
- Riot::Situation.instance_eval { include WebMock }
9
+
10
+ Riot::Situation.instance_eval { include WebMock::API }
10
11
 
11
12
  require 'riot/gear'
12
13
 
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: 17
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 7
10
- version: 0.0.7
9
+ - 8
10
+ version: 0.0.8
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-12 00:00:00 -05:00
18
+ date: 2010-12-23 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -54,10 +54,12 @@ dependencies:
54
54
  requirements:
55
55
  - - ">="
56
56
  - !ruby/object:Gem::Version
57
- hash: 3
57
+ hash: 13
58
58
  segments:
59
- - 0
60
- version: "0"
59
+ - 1
60
+ - 6
61
+ - 1
62
+ version: 1.6.1
61
63
  type: :development
62
64
  version_requirements: *id003
63
65
  description: Riot + HTTParty smoke testing framework. You'd use it for integration testing with real HTTP requests and responses
@@ -69,7 +71,6 @@ extensions: []
69
71
  extra_rdoc_files:
70
72
  - README.md
71
73
  files:
72
- - .gitignore
73
74
  - README.md
74
75
  - Rakefile
75
76
  - VERSION
@@ -86,6 +87,7 @@ files:
86
87
  - test/actions/get_test.rb
87
88
  - test/actions/post_test.rb
88
89
  - test/actions/put_test.rb
90
+ - test/assertions/asserts_json_test.rb
89
91
  - test/helpers/cookie_values_test.rb
90
92
  - test/helpers/json_path_test.rb
91
93
  - test/riotparty_proxy_methods_test.rb
@@ -96,8 +98,8 @@ homepage: http://github.com/thumblemonks/riot-gear
96
98
  licenses: []
97
99
 
98
100
  post_install_message:
99
- rdoc_options:
100
- - --charset=UTF-8
101
+ rdoc_options: []
102
+
101
103
  require_paths:
102
104
  - lib
103
105
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -130,6 +132,7 @@ test_files:
130
132
  - test/actions/get_test.rb
131
133
  - test/actions/post_test.rb
132
134
  - test/actions/put_test.rb
135
+ - test/assertions/asserts_json_test.rb
133
136
  - test/helpers/cookie_values_test.rb
134
137
  - test/helpers/json_path_test.rb
135
138
  - test/riotparty_proxy_methods_test.rb
data/.gitignore DELETED
@@ -1,5 +0,0 @@
1
- .DS_Store
2
- .bundle/*
3
- *.tmproj
4
- pkg/*
5
- .rvmrc