webspicy 0.20.22 → 0.20.23
Sign up to get free protection for your applications and to get access to all the features.
- 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/version.rb +1 -1
- data/spec/unit/support/test_deep_merge.rb +45 -0
- metadata +5 -3
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'
|
data/lib/webspicy/version.rb
CHANGED
@@ -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
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-12-
|
11
|
+
date: 2021-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -287,6 +287,7 @@ files:
|
|
287
287
|
- lib/webspicy/support.rb
|
288
288
|
- lib/webspicy/support/colorize.rb
|
289
289
|
- lib/webspicy/support/data_object.rb
|
290
|
+
- lib/webspicy/support/deep_merge.rb
|
290
291
|
- lib/webspicy/support/hooks.rb
|
291
292
|
- lib/webspicy/support/status_range.rb
|
292
293
|
- lib/webspicy/support/world.rb
|
@@ -354,6 +355,7 @@ files:
|
|
354
355
|
- spec/unit/support/hooks/test_fire_after_each.rb
|
355
356
|
- spec/unit/support/hooks/test_fire_around.rb
|
356
357
|
- spec/unit/support/hooks/test_fire_before_each.rb
|
358
|
+
- spec/unit/support/test_deep_merge.rb
|
357
359
|
- spec/unit/support/test_status_range.rb
|
358
360
|
- spec/unit/support/world/fixtures/array.json
|
359
361
|
- spec/unit/support/world/fixtures/queue.rb
|
@@ -392,7 +394,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
392
394
|
- !ruby/object:Gem::Version
|
393
395
|
version: '0'
|
394
396
|
requirements: []
|
395
|
-
rubygems_version: 3.
|
397
|
+
rubygems_version: 3.2.32
|
396
398
|
signing_key:
|
397
399
|
specification_version: 4
|
398
400
|
summary: Webspicy helps testing web services as software operation black boxes!
|