webspicy 0.20.19 → 0.20.23
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/webspicy/configuration/scope.rb +6 -13
- data/lib/webspicy/support/deep_merge.rb +36 -0
- data/lib/webspicy/support.rb +1 -0
- data/lib/webspicy/tester/fakesmtp/email.rb +4 -4
- data/lib/webspicy/version.rb +1 -1
- data/lib/webspicy/web/client/rack_test_client.rb +5 -3
- data/spec/unit/support/test_deep_merge.rb +45 -0
- metadata +16 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81d8ffb7aa9875416729a3b6226e621ea4140d4f30cc4852444c43ca8fbe5eb3
|
4
|
+
data.tar.gz: 8fa3e5471c7d732d21668ec99dfad7aa9fdb820f2e6fb41d180076206848c697
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07c62996f90df9ed4b7665712154edb3b0e9c59cdd25bea7c46520b0d4979a3e0c5cd127e0ac8bd2c08f060730d0f0f43609cc3d802b67a129e315eee0877568
|
7
|
+
data.tar.gz: a40f2056c7284919b4ef5aa520a7bafb07af8456737bf7944a51981fb44ac9d56389ea777ff51e0b8861bd2c8d43923bf6814784e80399775d9c123366d99f76
|
@@ -136,20 +136,13 @@ module Webspicy
|
|
136
136
|
|
137
137
|
def expand_example(service, example)
|
138
138
|
return example unless service.default_example
|
139
|
-
h1 = service.default_example.to_info
|
140
|
-
h2 = example.to_info
|
141
|
-
ex = config.factory.test_case(merge_maps(h1, h2), self)
|
142
|
-
ex.bind(service, example.counterexample?)
|
143
|
-
end
|
144
139
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
end
|
152
|
-
end
|
140
|
+
merged = Support::DeepMerge.deep_merge(
|
141
|
+
service.default_example.to_info,
|
142
|
+
example.to_info
|
143
|
+
)
|
144
|
+
ex = config.factory.test_case(merged, self)
|
145
|
+
ex.bind(service, example.counterexample?)
|
153
146
|
end
|
154
147
|
|
155
148
|
# Returns a proc that implements file_filter strategy according to the
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Webspicy
|
2
|
+
module Support
|
3
|
+
class DeepMerge
|
4
|
+
class << self
|
5
|
+
|
6
|
+
def deep_merge(h1, h2)
|
7
|
+
merge_maps(deep_dup(h1), deep_dup(h2))
|
8
|
+
end
|
9
|
+
|
10
|
+
def deep_dup(x)
|
11
|
+
case x
|
12
|
+
when Array
|
13
|
+
x.map{|y| deep_dup(y) }
|
14
|
+
when Hash
|
15
|
+
x.each_with_object({}){|(k,v),memo| memo[k] = deep_dup(v) }
|
16
|
+
else
|
17
|
+
x
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def merge_maps(h1, h2)
|
24
|
+
h1.merge(h2) do |k,v1,v2|
|
25
|
+
case v1
|
26
|
+
when Hash then merge_maps(v1, v2)
|
27
|
+
when Array then v1 + v2
|
28
|
+
else v2
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/webspicy/support.rb
CHANGED
@@ -28,6 +28,7 @@ module Webspicy
|
|
28
28
|
end # module Support
|
29
29
|
end # module Webspicy
|
30
30
|
require_relative 'support/data_object'
|
31
|
+
require_relative 'support/deep_merge'
|
31
32
|
require_relative 'support/status_range'
|
32
33
|
require_relative 'support/colorize'
|
33
34
|
require_relative 'support/world'
|
@@ -32,10 +32,10 @@ module Webspicy
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def subject
|
35
|
-
@subject ||= data["headerLines"]
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
@subject ||= data["subject"] || data["headerLines"]
|
36
|
+
.select{|h| h["key"] == "subject" }
|
37
|
+
.map{|h| h["line"][/Subject:\s*(.*)$/, 1] }
|
38
|
+
.first
|
39
39
|
end
|
40
40
|
|
41
41
|
def headers
|
data/lib/webspicy/version.rb
CHANGED
@@ -96,14 +96,16 @@ module Webspicy
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def post(url, params = {}, headers = nil, body = nil)
|
99
|
-
handler = get_handler(headers)
|
100
|
-
|
101
99
|
url = url + "?" + Rack::Utils.build_query(params) if body && !params.empty?
|
100
|
+
headers = {
|
101
|
+
"Content-Type" => "application/json"
|
102
|
+
}.merge(headers || {}) if body.nil?
|
103
|
+
handler = get_handler(headers)
|
102
104
|
|
103
105
|
case body
|
104
106
|
when NilClass
|
105
107
|
info_request("POST", url, params, headers, body)
|
106
|
-
handler.post(url, params.to_json,
|
108
|
+
handler.post(url, params.to_json, headers)
|
107
109
|
when FileUpload
|
108
110
|
file = Rack::Test::UploadedFile.new(body.path, body.content_type)
|
109
111
|
info_request("POST", url, params, headers, body)
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
module Webspicy
|
3
|
+
module Support
|
4
|
+
describe DeepMerge, 'deep_dup' do
|
5
|
+
it 'works on scalars' do
|
6
|
+
expect(DeepMerge.deep_dup(12)).to eql(12)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'works on arrays' do
|
10
|
+
xs = [1, 2, 3]
|
11
|
+
expect(DeepMerge.deep_dup(xs)).to eql(xs)
|
12
|
+
expect(DeepMerge.deep_dup(xs)).not_to be(xs)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'works on hashes' do
|
16
|
+
xs = { foo: "bar" }
|
17
|
+
expect(DeepMerge.deep_dup(xs)).to eql(xs)
|
18
|
+
expect(DeepMerge.deep_dup(xs)).not_to be(xs)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'works recursively' do
|
22
|
+
xs = { foo: { bar: [1, 2, 3] } }
|
23
|
+
got = DeepMerge.deep_dup(xs)
|
24
|
+
expect(got[:foo]).not_to be(xs[:foo])
|
25
|
+
expect(got[:foo][:bar]).not_to be(xs[:foo][:bar])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
describe DeepMerge, 'deep_merge' do
|
29
|
+
it 'works as expected' do
|
30
|
+
h1 = { foo: { bar: "baz" }, times: [1, 2], only: { me: true } }
|
31
|
+
h2 = { foo: { bor: "boz" }, times: [3, 4], not: { you: false } }
|
32
|
+
expected = {
|
33
|
+
foo: { bar: "baz", bor: "boz" },
|
34
|
+
times: [1, 2, 3, 4],
|
35
|
+
only: { me: true },
|
36
|
+
not: { you: false }
|
37
|
+
}
|
38
|
+
got = DeepMerge.deep_merge(h1, h2)
|
39
|
+
expect(got).to eql(expected)
|
40
|
+
expect(got[:only]).not_to be(h1[:only])
|
41
|
+
expect(got[:not]).not_to be(h2[:not])
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webspicy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.20.
|
4
|
+
version: 0.20.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernard Lambeau
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -84,16 +84,22 @@ dependencies:
|
|
84
84
|
name: finitio
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: 0.10.0
|
90
|
+
- - "<"
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 0.12.0
|
90
93
|
type: :runtime
|
91
94
|
prerelease: false
|
92
95
|
version_requirements: !ruby/object:Gem::Requirement
|
93
96
|
requirements:
|
94
|
-
- - "
|
97
|
+
- - ">="
|
95
98
|
- !ruby/object:Gem::Version
|
96
99
|
version: 0.10.0
|
100
|
+
- - "<"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 0.12.0
|
97
103
|
- !ruby/object:Gem::Dependency
|
98
104
|
name: http
|
99
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -281,6 +287,7 @@ files:
|
|
281
287
|
- lib/webspicy/support.rb
|
282
288
|
- lib/webspicy/support/colorize.rb
|
283
289
|
- lib/webspicy/support/data_object.rb
|
290
|
+
- lib/webspicy/support/deep_merge.rb
|
284
291
|
- lib/webspicy/support/hooks.rb
|
285
292
|
- lib/webspicy/support/status_range.rb
|
286
293
|
- lib/webspicy/support/world.rb
|
@@ -348,6 +355,7 @@ files:
|
|
348
355
|
- spec/unit/support/hooks/test_fire_after_each.rb
|
349
356
|
- spec/unit/support/hooks/test_fire_around.rb
|
350
357
|
- spec/unit/support/hooks/test_fire_before_each.rb
|
358
|
+
- spec/unit/support/test_deep_merge.rb
|
351
359
|
- spec/unit/support/test_status_range.rb
|
352
360
|
- spec/unit/support/world/fixtures/array.json
|
353
361
|
- spec/unit/support/world/fixtures/queue.rb
|
@@ -371,7 +379,7 @@ homepage: http://github.com/enspirit/webspicy
|
|
371
379
|
licenses:
|
372
380
|
- MIT
|
373
381
|
metadata: {}
|
374
|
-
post_install_message:
|
382
|
+
post_install_message:
|
375
383
|
rdoc_options: []
|
376
384
|
require_paths:
|
377
385
|
- lib
|
@@ -386,8 +394,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
386
394
|
- !ruby/object:Gem::Version
|
387
395
|
version: '0'
|
388
396
|
requirements: []
|
389
|
-
rubygems_version: 3.
|
390
|
-
signing_key:
|
397
|
+
rubygems_version: 3.2.32
|
398
|
+
signing_key:
|
391
399
|
specification_version: 4
|
392
400
|
summary: Webspicy helps testing web services as software operation black boxes!
|
393
401
|
test_files: []
|