riot-gear 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +5 -1
- data/lib/riot/gear/context.rb +0 -2
- data/lib/riot/gear/context/asserts_header.rb +2 -0
- data/lib/riot/gear/middleware/riotparty.rb +7 -8
- data/lib/riot/gear/version.rb +1 -2
- data/test/actions/options_test.rb +58 -0
- data/test/riotparty_proxy_methods_test.rb +1 -1
- metadata +4 -4
- data/lib/riot/gear/context/anything.rb +0 -24
- data/lib/riot/gear/context/asserts_cookie.rb +0 -20
data/CHANGELOG
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# @markup markdown
|
2
2
|
|
3
|
+
# 0.0.12
|
4
|
+
|
5
|
+
* Allow OPTIONS HTTP calls [rquinlivan]
|
6
|
+
|
3
7
|
# 0.0.10
|
4
8
|
|
5
9
|
* Defines a new setup block called `once`. Useful for running a single block before assertions, but only inside the context it was defined in [jaknowlden]
|
@@ -17,7 +21,7 @@ context ThingsMaker do
|
|
17
21
|
|
18
22
|
context "makes no more things" do
|
19
23
|
get "/things/2"
|
20
|
-
asserts_status(404) #
|
24
|
+
asserts_status(404) # because the post didn't run again ... see ... yeah
|
21
25
|
end
|
22
26
|
end
|
23
27
|
```
|
data/lib/riot/gear/context.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
require 'riot/gear/context/once'
|
2
|
-
require 'riot/gear/context/anything'
|
3
2
|
require 'riot/gear/context/persist_cookie'
|
4
3
|
require 'riot/gear/context/asserts_status'
|
5
4
|
require 'riot/gear/context/asserts_header'
|
6
|
-
require 'riot/gear/context/asserts_cookie'
|
7
5
|
require 'riot/gear/context/asserts_json'
|
@@ -45,15 +45,15 @@ private
|
|
45
45
|
# Returns the list of methods that do something; like make a network call.
|
46
46
|
#
|
47
47
|
# @return [Array<Symbol>]
|
48
|
-
def actionable_methods; [:get, :post, :put, :delete, :head]; end
|
48
|
+
def actionable_methods; [:get, :post, :put, :delete, :head, :options]; end
|
49
49
|
|
50
|
-
# Returns the list of methods that configure actionable HTTParty methods. The
|
51
|
-
# {HTTParty.default_options}
|
50
|
+
# Returns the list of methods that configure actionable HTTParty methods. The
|
51
|
+
# {HTTParty.default_options} method is explicitly excluded from this list
|
52
52
|
#
|
53
53
|
# @return [Array<Symbol>]
|
54
54
|
def proxiable_methods
|
55
55
|
methods = HTTParty::ClassMethods.instance_methods.map { |m| m.to_s.to_sym }
|
56
|
-
methods - actionable_methods - [:
|
56
|
+
methods - actionable_methods - [:default_options]
|
57
57
|
end
|
58
58
|
|
59
59
|
# Bind the set of actionable methods to a given context.
|
@@ -81,10 +81,8 @@ private
|
|
81
81
|
def proxy_action_methods(context)
|
82
82
|
context_eigen = (class << context; self; end)
|
83
83
|
actionable_methods.each do |method_name|
|
84
|
-
|
85
84
|
context_eigen.__send__(:define_method, method_name) do |*args, &settings_block|
|
86
|
-
|
87
|
-
anything do
|
85
|
+
hookup do
|
88
86
|
if settings_block
|
89
87
|
name = args.first
|
90
88
|
options = instance_eval(&settings_block)
|
@@ -93,12 +91,13 @@ private
|
|
93
91
|
name = nil
|
94
92
|
path, options = *args
|
95
93
|
end
|
94
|
+
#debug_start = Time.now
|
96
95
|
result = topic.__send__(method_name, path, options || {})
|
96
|
+
#puts "TIME #{(Time.now - debug_start) * 1000.0}ms #{topic.base_uri}#{path}"
|
97
97
|
@saved_responses[name] = result
|
98
98
|
@smoke_response = result # TODO remove this after it's certain no usages in the wild
|
99
99
|
end
|
100
100
|
end
|
101
|
-
|
102
101
|
end # methods.each
|
103
102
|
end
|
104
103
|
|
data/lib/riot/gear/version.rb
CHANGED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'teststrap'
|
2
|
+
|
3
|
+
context "Sending an OPTIONS request with a base uri" do
|
4
|
+
|
5
|
+
context "without params" do
|
6
|
+
hookup do
|
7
|
+
stub_request(:options, '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
|
+
options "/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(:options, '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
|
+
options "/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
|
35
|
+
base_uri "http://test.local"
|
36
|
+
options "/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(:options, '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
|
+
options 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
|
@@ -51,7 +51,7 @@ context "A Riot Gear context" do
|
|
51
51
|
|
52
52
|
asserts("providing an invalid format") do
|
53
53
|
topic.format :boogers
|
54
|
-
end.raises(HTTParty::UnsupportedFormat, "':boogers' Must be one of: html, json, plain, xml")
|
54
|
+
end.raises(HTTParty::UnsupportedFormat, "':boogers' Must be one of: csv, html, json, plain, xml")
|
55
55
|
|
56
56
|
debug_output StringIO.new
|
57
57
|
asserts("default options for debug_output") do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riot-gear
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-04-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: riot
|
@@ -60,8 +60,6 @@ files:
|
|
60
60
|
- Rakefile
|
61
61
|
- lib/riot/gear.rb
|
62
62
|
- lib/riot/gear/context.rb
|
63
|
-
- lib/riot/gear/context/anything.rb
|
64
|
-
- lib/riot/gear/context/asserts_cookie.rb
|
65
63
|
- lib/riot/gear/context/asserts_header.rb
|
66
64
|
- lib/riot/gear/context/asserts_json.rb
|
67
65
|
- lib/riot/gear/context/asserts_status.rb
|
@@ -73,6 +71,7 @@ files:
|
|
73
71
|
- riot-gear.gemspec
|
74
72
|
- test/actions/delete_test.rb
|
75
73
|
- test/actions/get_test.rb
|
74
|
+
- test/actions/options_test.rb
|
76
75
|
- test/actions/post_test.rb
|
77
76
|
- test/actions/put_test.rb
|
78
77
|
- test/assertions/asserts_json_test.rb
|
@@ -109,6 +108,7 @@ summary: Riot + HTTParty smoke testing framework.
|
|
109
108
|
test_files:
|
110
109
|
- test/actions/delete_test.rb
|
111
110
|
- test/actions/get_test.rb
|
111
|
+
- test/actions/options_test.rb
|
112
112
|
- test/actions/post_test.rb
|
113
113
|
- test/actions/put_test.rb
|
114
114
|
- test/assertions/asserts_json_test.rb
|
@@ -1,24 +0,0 @@
|
|
1
|
-
class Riot::Gear::AnythingRunnable < Riot::RunnableBlock
|
2
|
-
def initialize(description, &definition)
|
3
|
-
super("[anything] #{description}", &definition)
|
4
|
-
end
|
5
|
-
|
6
|
-
# @param [Riot::Situation] situation An instance of a {Riot::Situation}
|
7
|
-
# @return [Array<Symbol>]
|
8
|
-
def run(situation)
|
9
|
-
situation.evaluate(&definition)
|
10
|
-
[:anything]
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
module Riot::Gear::AnythingContextHelper
|
15
|
-
# @param [String] description A description of what the block is for
|
16
|
-
# @param [lambda] &definition The block that will be executed ...
|
17
|
-
# @return [Riot::Gear::AnythingRunnable]
|
18
|
-
def anything(description="", &definition)
|
19
|
-
@assertions << Riot::Gear::AnythingRunnable.new(description, &definition)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
Riot::Context.instance_eval { include Riot::Gear::AnythingContextHelper }
|
24
|
-
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Riot
|
2
|
-
module Gear
|
3
|
-
module AssertsCookie
|
4
|
-
|
5
|
-
# Generates an assertion that retrieves the value of some cookie from the last response.
|
6
|
-
#
|
7
|
-
# asserts_cookie("ui_session").matches(/stuff/)
|
8
|
-
#
|
9
|
-
# @param [String] cookie-name the name of the cookie
|
10
|
-
# @return [Riot::Assertion] an assertion block that macros can be applied to
|
11
|
-
def asserts_cookie(cookie_name)
|
12
|
-
asserts("set-cookie #{cookie_name}") { cookie_values[cookie_name] }
|
13
|
-
end
|
14
|
-
|
15
|
-
end # AssertsHeader
|
16
|
-
end # Gear
|
17
|
-
end # Riot
|
18
|
-
|
19
|
-
Riot::Context.instance_eval { include Riot::Gear::AssertsCookie }
|
20
|
-
|