dock_test 0.0.3 → 0.1.0
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.
- checksums.yaml +4 -4
- data/lib/dock_test/assertions.rb +5 -4
- data/lib/dock_test/dsl.rb +44 -0
- data/lib/dock_test/version.rb +1 -1
- data/lib/dock_test.rb +4 -42
- data/test/test_helper.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2593cb3492af382c4c090f672028a58e0a3b9c0b
|
4
|
+
data.tar.gz: 4bee1ab15ad6a3c4b9338abb3ec440fe712f07f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76960e6d4db18d638ba19ad7d55c737338aa751db20b66a7f13e925ec87fc69b1ffd044b6f1736aeaa0150c467ca074ad62d504bb8004e11f728ce8be4e9a182
|
7
|
+
data.tar.gz: eecf368bab9ce45dd794f97cbdb9b91ab09b5edb58bfe42390c38940f33a3e1b34fd74567137e6e9b7f6384b57608afaec4fc2d8d2f7c22d5de66748f1cc807c
|
data/lib/dock_test/assertions.rb
CHANGED
@@ -1,23 +1,24 @@
|
|
1
1
|
module Minitest::Assertions
|
2
2
|
def assert_response_status(status)
|
3
|
-
assert last_response.code == status.to_s, "The response status is
|
3
|
+
assert last_response.code == status.to_s, "The actual response status is #{last_response.code}"
|
4
4
|
end
|
5
5
|
|
6
6
|
def assert_response_content_type(content_type)
|
7
|
-
assert last_response['Content-Type'] == content_type.to_s, "The response content_type is
|
7
|
+
assert last_response['Content-Type'] == content_type.to_s, "The actual response content_type is #{last_response['Content-Type']}"
|
8
8
|
end
|
9
9
|
|
10
10
|
def assert_response_headers(headers, options = {})
|
11
11
|
exclude_keys = Array(options[:exclude] || [])
|
12
12
|
response_headers = last_response.to_hash.delete_if {|k, _| exclude_keys.include?(k)}
|
13
|
+
assert response_headers == headers, "The actual response headers are #{response_headers.inspect}"
|
13
14
|
end
|
14
15
|
|
15
16
|
def assert_response_body(body_string)
|
16
|
-
assert last_response.body == body_string, "The response body is
|
17
|
+
assert last_response.body == body_string, "The actual response body is #{last_response.body}"
|
17
18
|
end
|
18
19
|
|
19
20
|
def assert_response_json_schema(schema_path)
|
20
21
|
schema = File.open(schema_path).read
|
21
|
-
assert JSON::Validator.validate(schema, last_response.body), "The response
|
22
|
+
assert JSON::Validator.validate(schema, last_response.body), "The actual response does not match the schema defined in #{schema_path}"
|
22
23
|
end
|
23
24
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module DockTest
|
2
|
+
module DSL
|
3
|
+
|
4
|
+
attr_reader :url
|
5
|
+
# sets the test url
|
6
|
+
# also creates a new webrick server process
|
7
|
+
def url=(value)
|
8
|
+
@url = value
|
9
|
+
|
10
|
+
if localhost? && @server_thread.nil?
|
11
|
+
require "rack"
|
12
|
+
require 'webrick'
|
13
|
+
server = WEBrick::HTTPServer.new(:Port => port).tap do |server|
|
14
|
+
server.mount '/', Rack::Handler::WEBrick, Rack::Server.new.app
|
15
|
+
end
|
16
|
+
@server_thread = Thread.new { server.start }
|
17
|
+
trap('INT') do
|
18
|
+
server.shutdown
|
19
|
+
exit
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def port
|
25
|
+
URI.parse(@url).port
|
26
|
+
end
|
27
|
+
|
28
|
+
def localhost?
|
29
|
+
@url && ['127.0.0.1', 'localhost'].include?(URI.parse(@url).host)
|
30
|
+
end
|
31
|
+
|
32
|
+
def skippy=(envs)
|
33
|
+
@skippy_envs = Array(envs).map(&:to_s)
|
34
|
+
end
|
35
|
+
|
36
|
+
def skippy_envs
|
37
|
+
@skippy_envs ||= ['production']
|
38
|
+
end
|
39
|
+
|
40
|
+
def configure(&block)
|
41
|
+
block.call(DockTest)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/dock_test/version.rb
CHANGED
data/lib/dock_test.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'multi_json'
|
2
2
|
require 'json-schema'
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'dock_test/version'
|
4
|
+
require 'dock_test/methods'
|
5
|
+
require 'dock_test/dsl'
|
5
6
|
|
6
7
|
if defined?(::Minitest)
|
7
8
|
require 'dock_test/assertions'
|
@@ -9,44 +10,5 @@ else
|
|
9
10
|
end
|
10
11
|
|
11
12
|
module DockTest
|
12
|
-
|
13
|
-
class << self
|
14
|
-
|
15
|
-
attr_reader :url
|
16
|
-
# sets the test url
|
17
|
-
# also creates a new webrick server process
|
18
|
-
def url=(value)
|
19
|
-
@url = value
|
20
|
-
|
21
|
-
if localhost? && @server_thread.nil?
|
22
|
-
require "rack"
|
23
|
-
require 'webrick'
|
24
|
-
server = WEBrick::HTTPServer.new(:Port => port).tap do |server|
|
25
|
-
server.mount '/', Rack::Handler::WEBrick, Rack::Server.new.app
|
26
|
-
end
|
27
|
-
@server_thread = Thread.new { server.start }
|
28
|
-
trap('INT') do
|
29
|
-
server.shutdown
|
30
|
-
exit
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def port
|
36
|
-
URI.parse(@url).port
|
37
|
-
end
|
38
|
-
|
39
|
-
def localhost?
|
40
|
-
@url && ['127.0.0.1', 'localhost'].include?(URI.parse(@url).host)
|
41
|
-
end
|
42
|
-
|
43
|
-
attr_reader :skippy_envs
|
44
|
-
def skippy=(envs)
|
45
|
-
@skippy_envs = Array(envs).map(&:to_s)
|
46
|
-
end
|
47
|
-
|
48
|
-
def config(&block)
|
49
|
-
block.call(DockTest)
|
50
|
-
end
|
51
|
-
end
|
13
|
+
extend DSL
|
52
14
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dock_test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jack Xu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- dock_test.gemspec
|
98
98
|
- lib/dock_test.rb
|
99
99
|
- lib/dock_test/assertions.rb
|
100
|
+
- lib/dock_test/dsl.rb
|
100
101
|
- lib/dock_test/methods.rb
|
101
102
|
- lib/dock_test/version.rb
|
102
103
|
- schemas/response.schema.json
|