webspicy 0.20.20 → 0.20.24

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1540c9120b24bed9351dc01d8906cad2f4ffac8ea478c4e5cdf23ec48e3439d
4
- data.tar.gz: a188f120ff0bed71f12ed525916ccafdb89e1c62d9fe6e5fc8acc1e7576d1e40
3
+ metadata.gz: 358d398af31550346d16e0b0aea1fbdbbdb6d9b6097adc0f53642faf73605447
4
+ data.tar.gz: 73bbb61d76edb81151a2d201b51a8e509d79728145a524f04a33bb80696ced46
5
5
  SHA512:
6
- metadata.gz: 582f993602ffec966ee10e7339806ce747acb5b6f93a89a9427687bb4ce098200a33fd99db9adf4fd70575177b25f07b2a3a9014f3513a17a261e0a62c797b3e
7
- data.tar.gz: 1d42856145ee337d16bfdf85c2e94eaa8b144d8e089b9cadc4d71e607bf023ed9856d229169ca511f80111350255133f1c1c5e6c6a66cea490eff4e2d2ae5a49
6
+ metadata.gz: 641ccd34d62b106ac983ed192fb54f313dfd03a1a068a95018e84fdb840a0e54dfa3d410617a2fb357519eebd344e3f179e7cdac0cc7ae61b43b51a770f32284
7
+ data.tar.gz: f9ed1ae27dbaae00369437622f04610391225ce39c19636e430cb5e10f1606a52b50582aa01a83a611aee61aab673a4eb67f94d340f21906924409020713f886
@@ -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
- def merge_maps(h1, h2)
146
- h1.merge(h2) do |k,v1,v2|
147
- case v1
148
- when Hash then merge_maps(v1, v2)
149
- when Array then v1 + v2
150
- else v2
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
@@ -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'
@@ -51,16 +51,14 @@ module Webspicy
51
51
  end
52
52
 
53
53
  def before_service
54
- @spec_file_line_printed = false
54
+ @test_case_seen = false
55
55
  end
56
56
 
57
57
  def before_test_case
58
- unless @spec_file_line_printed
59
- io.puts spec_file_line(spec_file)
60
- io.puts
61
- io.flush
62
- @spec_file_line_printed = true
63
- end
58
+ @test_case_seen = true
59
+ io.puts spec_file_line(spec_file)
60
+ io.puts
61
+ io.flush
64
62
  io.puts service_line(service, test_case)
65
63
  io.flush
66
64
  end
@@ -86,10 +84,8 @@ module Webspicy
86
84
  end
87
85
 
88
86
  def service_done
89
- unless @spec_file_line_printed
90
- io.puts
91
- io.flush
92
- end
87
+ io.puts if @test_case_seen
88
+ io.flush
93
89
  end
94
90
 
95
91
  end # class Documentation
@@ -2,7 +2,7 @@ module Webspicy
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 20
5
- TINY = 20
5
+ TINY = 24
6
6
  end
7
7
  VERSION = "#{Version::MAJOR}.#{Version::MINOR}.#{Version::TINY}"
8
8
  end
@@ -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, {"CONTENT_TYPE" => "application/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.20
4
+ version: 0.20.24
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-25 00:00:00.000000000 Z
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.1.4
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: []