webspicy 0.15.8 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +71 -24
  3. data/bin/webspicy +30 -14
  4. data/examples/restful/Gemfile.lock +38 -23
  5. data/examples/restful/Rakefile +0 -1
  6. data/examples/restful/app.rb +4 -1
  7. data/examples/restful/webspicy/config.rb +8 -0
  8. data/examples/restful/webspicy/rack.rb +1 -1
  9. data/examples/restful/webspicy/real.rb +1 -1
  10. data/examples/restful/webspicy/schema.fio +2 -2
  11. data/examples/restful/webspicy/support/must_be_authenticated.rb +2 -2
  12. data/examples/restful/webspicy/support/todo_removed.rb +18 -0
  13. data/examples/restful/webspicy/todo/deleteTodo.yml +4 -1
  14. data/examples/restful/webspicy/todo/getTodoSingleServiceFormat.yml +46 -0
  15. data/examples/restful/webspicy/todo/options.yml +1 -1
  16. data/examples/restful/webspicy/todo/patchTodo.yml +3 -0
  17. data/examples/restful/webspicy/todo/postFile.yml +1 -1
  18. data/examples/single_spec/spec.yml +59 -0
  19. data/examples/website/config.rb +2 -0
  20. data/examples/website/schema.fio +1 -0
  21. data/examples/website/specification/get-http.yml +34 -0
  22. data/examples/website/specification/get-https.yml +34 -0
  23. data/lib/finitio/webspicy/scalars.fio +25 -0
  24. data/lib/webspicy.rb +48 -17
  25. data/lib/webspicy/checker.rb +2 -2
  26. data/lib/webspicy/configuration.rb +70 -14
  27. data/lib/webspicy/configuration/scope.rb +162 -0
  28. data/lib/webspicy/configuration/single_url.rb +58 -0
  29. data/lib/webspicy/configuration/single_yml_file.rb +30 -0
  30. data/lib/webspicy/formaldoc.fio +23 -8
  31. data/lib/webspicy/mocker.rb +8 -8
  32. data/lib/webspicy/openapi.rb +1 -0
  33. data/lib/webspicy/openapi/generator.rb +127 -0
  34. data/lib/webspicy/{resource.rb → specification.rb} +26 -5
  35. data/lib/webspicy/specification/file_upload.rb +37 -0
  36. data/lib/webspicy/specification/postcondition.rb +16 -0
  37. data/lib/webspicy/specification/precondition.rb +19 -0
  38. data/lib/webspicy/specification/precondition/global_request_headers.rb +35 -0
  39. data/lib/webspicy/specification/precondition/robust_to_invalid_input.rb +68 -0
  40. data/lib/webspicy/{resource → specification}/service.rb +11 -6
  41. data/lib/webspicy/specification/test_case.rb +139 -0
  42. data/lib/webspicy/support.rb +1 -0
  43. data/lib/webspicy/support/colorize.rb +28 -0
  44. data/lib/webspicy/support/status_range.rb +6 -1
  45. data/lib/webspicy/tester.rb +16 -11
  46. data/lib/webspicy/tester/asserter.rb +3 -2
  47. data/lib/webspicy/tester/assertions.rb +5 -1
  48. data/lib/webspicy/tester/client.rb +63 -0
  49. data/lib/webspicy/tester/client/http_client.rb +154 -0
  50. data/lib/webspicy/tester/client/rack_test_client.rb +188 -0
  51. data/lib/webspicy/tester/client/support.rb +65 -0
  52. data/lib/webspicy/tester/invocation.rb +218 -0
  53. data/lib/webspicy/tester/rspec_asserter.rb +108 -0
  54. data/lib/webspicy/tester/rspec_matchers.rb +104 -0
  55. data/lib/webspicy/version.rb +2 -2
  56. data/spec/{unit/spec_helper.rb → spec_helper.rb} +0 -0
  57. data/spec/unit/configuration/scope/test_each_service.rb +49 -0
  58. data/spec/unit/configuration/scope/test_each_specification.rb +68 -0
  59. data/spec/unit/configuration/scope/test_expand_example.rb +65 -0
  60. data/spec/unit/configuration/scope/test_to_real_url.rb +82 -0
  61. data/spec/unit/openapi/test_generator.rb +28 -0
  62. data/spec/unit/specification/precondition/test_global_request_headers.rb +42 -0
  63. data/spec/unit/{resource → specification}/service/test_dress_params.rb +2 -2
  64. data/spec/unit/specification/test_case/test_mutate.rb +24 -0
  65. data/spec/unit/{resource → specification}/test_instantiate_url.rb +5 -5
  66. data/spec/unit/{resource → specification}/test_url_placeholders.rb +4 -4
  67. data/spec/unit/test_configuration.rb +24 -7
  68. data/spec/unit/tester/client/test_around.rb +61 -0
  69. data/spec/unit/tester/test_asserter.rb +51 -0
  70. data/spec/unit/tester/test_assertions.rb +4 -4
  71. data/tasks/test.rake +3 -1
  72. metadata +83 -34
  73. data/lib/webspicy/client.rb +0 -61
  74. data/lib/webspicy/client/http_client.rb +0 -145
  75. data/lib/webspicy/client/rack_test_client.rb +0 -181
  76. data/lib/webspicy/client/support.rb +0 -48
  77. data/lib/webspicy/file_upload.rb +0 -35
  78. data/lib/webspicy/postcondition.rb +0 -14
  79. data/lib/webspicy/precondition.rb +0 -15
  80. data/lib/webspicy/resource/service/invocation.rb +0 -212
  81. data/lib/webspicy/resource/service/test_case.rb +0 -132
  82. data/lib/webspicy/scope.rb +0 -160
  83. data/spec/unit/client/test_around.rb +0 -59
  84. data/spec/unit/scope/test_each_resource.rb +0 -66
  85. data/spec/unit/scope/test_each_service.rb +0 -47
  86. data/spec/unit/scope/test_expand_example.rb +0 -63
  87. data/spec/unit/scope/test_to_real_url.rb +0 -80
@@ -31,6 +31,23 @@ module Webspicy
31
31
  expect(c.preconditions.size).to eq(1)
32
32
  end
33
33
 
34
+ it 'supports an URL and returns a specific configuration instance' do
35
+ c = Configuration.dress("http://google.com/")
36
+ expect(c).to be_a(Configuration)
37
+ expect(c.folder).to eq(Path.pwd)
38
+ expect(c.each_scope.to_a.size).to eql(1)
39
+ expect(c.each_scope.to_a.first.each_specification.to_a.size).to eql(1)
40
+ end
41
+
42
+ it 'supports a single .yml file and returns a specific configuration instance' do
43
+ file = restful_folder/"todo/getTodo.yml"
44
+ c = Configuration.dress(file)
45
+ expect(c).to be_a(Configuration)
46
+ expect(c.folder).to eq(restful_folder)
47
+ expect(c.each_scope.to_a.size).to eql(1)
48
+ expect(c.each_scope.to_a.first.each_specification.to_a.size).to eql(1)
49
+ end
50
+
34
51
  it 'yields the block with the configuration, if given' do
35
52
  seen = nil
36
53
  Configuration.dress(Path.dir/'configuration'){|c|
@@ -56,20 +73,20 @@ module Webspicy
56
73
 
57
74
  it 'creates a child when adding a folder' do
58
75
  Configuration.new(Path.dir) do |c|
59
- child = c.folder 'resource'
76
+ child = c.folder 'specification'
60
77
  expect(child).to be_a(Configuration)
61
- expect(child.folder).to eql(Path.dir/'resource')
78
+ expect(child.folder).to eql(Path.dir/'specification')
62
79
  end
63
80
  end
64
81
 
65
82
  it 'yield the child to the block if any given' do
66
83
  Configuration.new(Path.dir) do |c|
67
84
  seen = nil
68
- c.folder 'resource' do |child|
85
+ c.folder 'specification' do |child|
69
86
  seen = child
70
87
  end
71
88
  expect(seen).to be_a(Configuration)
72
- expect(seen.folder).to eql(Path.dir/'resource')
89
+ expect(seen.folder).to eql(Path.dir/'specification')
73
90
  end
74
91
  end
75
92
  end
@@ -223,7 +240,7 @@ module Webspicy
223
240
  let(:before_aller) { ->(){} }
224
241
  let(:after_aller) { ->(){} }
225
242
  let(:config) do
226
- Configuration.new(Path.dir/'resource') do |c|
243
+ Configuration.new(Path.dir/'specification') do |c|
227
244
  c.before_all(&before_aller)
228
245
  c.before_each(&before_eacher)
229
246
  c.after_each(&after_eacher)
@@ -243,7 +260,7 @@ module Webspicy
243
260
  describe 'dup' do
244
261
 
245
262
  let(:original) do
246
- Configuration.new(Path.dir/'resource') do |c|
263
+ Configuration.new(Path.dir/'specification') do |c|
247
264
  c.host = "http://127.0.0.1"
248
265
  c.folder 'service'
249
266
  end
@@ -253,7 +270,7 @@ module Webspicy
253
270
  duped = original.dup do |d|
254
271
  d.host = "http://127.0.0.1:4567"
255
272
  end
256
- expect(duped.folder).to eql(Path.dir/'resource')
273
+ expect(duped.folder).to eql(Path.dir/'specification')
257
274
  expect(duped.host).to eql("http://127.0.0.1:4567")
258
275
  expect(original.host).to eql("http://127.0.0.1")
259
276
  end
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+ module Webspicy
3
+ class Tester
4
+ describe Client, "around" do
5
+
6
+ it 'work with no around at all' do
7
+ config = Configuration.new
8
+
9
+ seen = false
10
+ block = ->(){ seen = true }
11
+
12
+ scope = Configuration::Scope.new(config)
13
+ Client.new(scope).around(1, 2, 3, &block)
14
+ expect(seen).to be(true)
15
+ end
16
+
17
+ it 'work with one around' do
18
+ config = Configuration.new
19
+
20
+ seen = false
21
+ seen_args = nil
22
+ config.around_each do |*args, &bl|
23
+ seen_args = args
24
+ bl.call
25
+ end
26
+
27
+ scope = Configuration::Scope.new(config)
28
+ block = ->(){ seen = true }
29
+ Client.new(scope).around(1, 2, 3, &block)
30
+
31
+ expect(seen_args[0...-1]).to eql([1, 2, 3])
32
+ expect(seen).to be(true)
33
+ end
34
+
35
+ it 'works with two arounds' do
36
+ config = Configuration.new
37
+
38
+ seen = false
39
+
40
+ seen_args = []
41
+ config.around_each do |*args, &bl|
42
+ seen_args << args
43
+ bl.call
44
+ end
45
+ config.around_each do |*args, &bl|
46
+ seen_args << args
47
+ bl.call
48
+ end
49
+
50
+ scope = Configuration::Scope.new(config)
51
+ block = ->(){ seen = true }
52
+ Client.new(scope).around(1, 2, 3, &block)
53
+
54
+ expect(seen_args.size).to eql(2)
55
+ expect(seen_args.all?{|sa| sa[0...-1] == [1,2,3] }).to be(true)
56
+ expect(seen).to be(true)
57
+ end
58
+
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ module Webspicy
4
+ class Tester
5
+ describe Asserter do
6
+ let(:asserter) { Asserter.new(target) }
7
+
8
+ describe '#size' do
9
+ let(:target) { [1, 2, 3, 4] }
10
+
11
+ it 'returns nil when the assertion is true for a plain array' do
12
+ expect(asserter.size('', 4)).to eq nil
13
+ end
14
+
15
+ it 'raises an exception with a descriptive message when the assertion is false' do
16
+ expect { asserter.size('', 3) }
17
+ .to raise_exception RuntimeError, 'Expected [1,2,3,4] to have a size of 3, actual size is: 4'
18
+ end
19
+
20
+ context 'with a string' do
21
+ let(:target) { 'FooBaz' }
22
+
23
+ it 'returns nil when the assertion is true' do
24
+ expect(asserter.size('', 6)).to eq nil
25
+ end
26
+ end
27
+
28
+ context 'with an array at a nested path' do
29
+ let(:target) { { foo: [1, 2, { bar: [10, 11, 12] }, 4] } }
30
+
31
+ it 'returns nil when the assertion is true' do
32
+ expect(asserter.size('foo/2/bar', 3)).to eq nil
33
+ end
34
+
35
+ it 'raises an exception with a descriptive message when the assertion is false' do
36
+ expect { asserter.size('foo/2/bar', 99) }
37
+ .to raise_exception RuntimeError,
38
+ 'Expected [10,11,12] to have a size of 99, actual size is: 3'
39
+ end
40
+
41
+ it 'raises an InvalidArgError when the path is invalid' do
42
+ expect { asserter.size('foo/28/bar', 99) }
43
+ .to raise_exception Webspicy::Tester::Assertions::InvalidArgError,
44
+ 'Expecting instance responding to size'
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+
@@ -23,7 +23,7 @@ module Webspicy
23
23
  expect(includes [5, 1], 1).to be(true)
24
24
  end
25
25
 
26
- it 'has an notIcludes() assertion' do
26
+ it 'has a notIncludes() assertion' do
27
27
  expect(notIncludes [], 1).to be(true)
28
28
  expect(notIncludes [5, 1], 1).to be(false)
29
29
  end
@@ -37,7 +37,7 @@ module Webspicy
37
37
  expect(exists({ foo: {} }, 'foo/bar')).to be(false)
38
38
  end
39
39
 
40
- it 'has an notExists() assertion' do
40
+ it 'has a notExists() assertion' do
41
41
  expect(notExists nil).to be(true)
42
42
  expect(notExists []).to be(false)
43
43
  expect(notExists [1]).to be(false)
@@ -60,7 +60,7 @@ module Webspicy
60
60
  expect(notEmpty({ foo: [1] }, 'foo')).to be(true)
61
61
  end
62
62
 
63
- it 'has an size() assertion' do
63
+ it 'has a size() assertion' do
64
64
  expect(size [], 0).to be(true)
65
65
  expect(size [], 1).to be(false)
66
66
  expect(size [12], 1).to be(true)
@@ -106,7 +106,7 @@ module Webspicy
106
106
  expect(idFD(target, 'foo', 1, baz: "boz")).to be(false)
107
107
  end
108
108
 
109
- it 'has an pathFD assertion' do
109
+ it 'has a pathFD assertion' do
110
110
  target = { foo: { bar: "baz"} }
111
111
  expect(pathFD(target, 'foo', bar: "baz")).to be(true)
112
112
  expect(pathFD(target, 'foo', bar: "boz")).to be(false)
@@ -11,7 +11,9 @@ namespace :test do
11
11
  tests << :unit
12
12
 
13
13
  require 'path'
14
- Path.dir.parent.glob("examples/*").select{|f| f.directory? }.each do |file|
14
+ Path.dir.parent.glob("examples/*").select{|f|
15
+ f.directory? && (f/"Rakefile").exists?
16
+ }.each do |file|
15
17
  test_name = file.basename.to_s.to_sym
16
18
  desc "Runs the integration tests on the #{file.basename} example"
17
19
  task(test_name) do
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.15.8
4
+ version: 0.16.0
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: 2020-08-28 00:00:00.000000000 Z
11
+ date: 2020-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -84,16 +84,16 @@ dependencies:
84
84
  name: finitio
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.8.0
89
+ version: 0.9.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.8.0
96
+ version: 0.9.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: http
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -112,16 +112,16 @@ dependencies:
112
112
  name: path
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '1.3'
117
+ version: '2.0'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '1.3'
124
+ version: '2.0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rack-robustness
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -170,6 +170,34 @@ dependencies:
170
170
  - - ">="
171
171
  - !ruby/object:Gem::Version
172
172
  version: '0'
173
+ - !ruby/object:Gem::Dependency
174
+ name: colorize
175
+ requirement: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - "~>"
178
+ - !ruby/object:Gem::Version
179
+ version: 0.8.1
180
+ type: :runtime
181
+ prerelease: false
182
+ version_requirements: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - "~>"
185
+ - !ruby/object:Gem::Version
186
+ version: 0.8.1
187
+ - !ruby/object:Gem::Dependency
188
+ name: openapi3_parser
189
+ requirement: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - "~>"
192
+ - !ruby/object:Gem::Version
193
+ version: 0.8.2
194
+ type: :runtime
195
+ prerelease: false
196
+ version_requirements: !ruby/object:Gem::Requirement
197
+ requirements:
198
+ - - "~>"
199
+ - !ruby/object:Gem::Version
200
+ version: 0.8.2
173
201
  description: Webspicy helps testing web services as software operation black boxes
174
202
  email: blambeau@gmail.com
175
203
  executables:
@@ -192,8 +220,10 @@ files:
192
220
  - examples/restful/webspicy/schema.fio
193
221
  - examples/restful/webspicy/support/must_be_an_admin.rb
194
222
  - examples/restful/webspicy/support/must_be_authenticated.rb
223
+ - examples/restful/webspicy/support/todo_removed.rb
195
224
  - examples/restful/webspicy/todo/deleteTodo.yml
196
225
  - examples/restful/webspicy/todo/getTodo.yml
226
+ - examples/restful/webspicy/todo/getTodoSingleServiceFormat.yml
197
227
  - examples/restful/webspicy/todo/getTodos.yml
198
228
  - examples/restful/webspicy/todo/options.yml
199
229
  - examples/restful/webspicy/todo/patchTodo.yml
@@ -202,42 +232,61 @@ files:
202
232
  - examples/restful/webspicy/todo/postTodos.yml
203
233
  - examples/restful/webspicy/todo/putTodo.yml
204
234
  - examples/restful/webspicy/todo/todos.csv
235
+ - examples/single_spec/spec.yml
236
+ - examples/website/config.rb
237
+ - examples/website/schema.fio
238
+ - examples/website/specification/get-http.yml
239
+ - examples/website/specification/get-https.yml
240
+ - lib/finitio/webspicy/scalars.fio
205
241
  - lib/webspicy.rb
206
242
  - lib/webspicy/checker.rb
207
- - lib/webspicy/client.rb
208
- - lib/webspicy/client/http_client.rb
209
- - lib/webspicy/client/rack_test_client.rb
210
- - lib/webspicy/client/support.rb
211
243
  - lib/webspicy/configuration.rb
212
- - lib/webspicy/file_upload.rb
244
+ - lib/webspicy/configuration/scope.rb
245
+ - lib/webspicy/configuration/single_url.rb
246
+ - lib/webspicy/configuration/single_yml_file.rb
213
247
  - lib/webspicy/formaldoc.fio
214
248
  - lib/webspicy/mocker.rb
215
- - lib/webspicy/postcondition.rb
216
- - lib/webspicy/precondition.rb
217
- - lib/webspicy/resource.rb
218
- - lib/webspicy/resource/service.rb
219
- - lib/webspicy/resource/service/invocation.rb
220
- - lib/webspicy/resource/service/test_case.rb
221
- - lib/webspicy/scope.rb
249
+ - lib/webspicy/openapi.rb
250
+ - lib/webspicy/openapi/generator.rb
251
+ - lib/webspicy/specification.rb
252
+ - lib/webspicy/specification/file_upload.rb
253
+ - lib/webspicy/specification/postcondition.rb
254
+ - lib/webspicy/specification/precondition.rb
255
+ - lib/webspicy/specification/precondition/global_request_headers.rb
256
+ - lib/webspicy/specification/precondition/robust_to_invalid_input.rb
257
+ - lib/webspicy/specification/service.rb
258
+ - lib/webspicy/specification/test_case.rb
222
259
  - lib/webspicy/support.rb
260
+ - lib/webspicy/support/colorize.rb
223
261
  - lib/webspicy/support/status_range.rb
224
262
  - lib/webspicy/tester.rb
225
263
  - lib/webspicy/tester/asserter.rb
226
264
  - lib/webspicy/tester/assertions.rb
265
+ - lib/webspicy/tester/client.rb
266
+ - lib/webspicy/tester/client/http_client.rb
267
+ - lib/webspicy/tester/client/rack_test_client.rb
268
+ - lib/webspicy/tester/client/support.rb
269
+ - lib/webspicy/tester/invocation.rb
270
+ - lib/webspicy/tester/rspec_asserter.rb
271
+ - lib/webspicy/tester/rspec_matchers.rb
227
272
  - lib/webspicy/version.rb
228
- - spec/unit/client/test_around.rb
273
+ - spec/spec_helper.rb
229
274
  - spec/unit/configuration/config.rb
275
+ - spec/unit/configuration/scope/test_each_service.rb
276
+ - spec/unit/configuration/scope/test_each_specification.rb
277
+ - spec/unit/configuration/scope/test_expand_example.rb
278
+ - spec/unit/configuration/scope/test_to_real_url.rb
230
279
  - spec/unit/mocker/test_mocker.rb
231
- - spec/unit/resource/service/test_dress_params.rb
232
- - spec/unit/resource/test_instantiate_url.rb
233
- - spec/unit/resource/test_url_placeholders.rb
234
- - spec/unit/scope/test_each_resource.rb
235
- - spec/unit/scope/test_each_service.rb
236
- - spec/unit/scope/test_expand_example.rb
237
- - spec/unit/scope/test_to_real_url.rb
238
- - spec/unit/spec_helper.rb
280
+ - spec/unit/openapi/test_generator.rb
281
+ - spec/unit/specification/precondition/test_global_request_headers.rb
282
+ - spec/unit/specification/service/test_dress_params.rb
283
+ - spec/unit/specification/test_case/test_mutate.rb
284
+ - spec/unit/specification/test_instantiate_url.rb
285
+ - spec/unit/specification/test_url_placeholders.rb
239
286
  - spec/unit/support/test_status_range.rb
240
287
  - spec/unit/test_configuration.rb
288
+ - spec/unit/tester/client/test_around.rb
289
+ - spec/unit/tester/test_asserter.rb
241
290
  - spec/unit/tester/test_assertions.rb
242
291
  - tasks/gem.rake
243
292
  - tasks/test.rake
@@ -245,7 +294,7 @@ homepage: http://github.com/enspirit/webspicy
245
294
  licenses:
246
295
  - MIT
247
296
  metadata: {}
248
- post_install_message:
297
+ post_install_message:
249
298
  rdoc_options: []
250
299
  require_paths:
251
300
  - lib
@@ -261,7 +310,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
261
310
  version: '0'
262
311
  requirements: []
263
312
  rubygems_version: 3.1.2
264
- signing_key:
313
+ signing_key:
265
314
  specification_version: 4
266
315
  summary: Webspicy helps testing web services as software operation black boxes!
267
316
  test_files: []
@@ -1,61 +0,0 @@
1
- module Webspicy
2
- class Client
3
-
4
- def initialize(scope)
5
- @scope = scope
6
- end
7
- attr_reader :scope
8
-
9
- def config
10
- scope.config
11
- end
12
-
13
- def around(*args, &bl)
14
- args << self
15
- ls = config.listeners(:around_each)
16
- if ls.size == 0
17
- bl.call
18
- elsif ls.size > 1
19
- _around(ls.first, ls[1..-1], args, &bl)
20
- else
21
- ls.first.call(*args, &bl)
22
- end
23
- end
24
-
25
- def _around(head, tail, args, &bl)
26
- head.call(*args) do
27
- if tail.empty?
28
- bl.call
29
- else
30
- _around(tail.first, tail[1..-1], args, &bl)
31
- end
32
- end
33
- end
34
- private :_around
35
-
36
- def instrument(*args, &bl)
37
- args << self
38
- config.listeners(:instrument).each do |i|
39
- i.call(*args, &bl)
40
- end
41
- end
42
-
43
- def before(*args, &bl)
44
- args << self
45
- config.listeners(:before_each).each do |beach|
46
- beach.call(*args, &bl)
47
- end
48
- end
49
-
50
- def after(*args, &bl)
51
- args << self
52
- config.listeners(:after_each).each do |aeach|
53
- aeach.call(*args, &bl)
54
- end
55
- end
56
-
57
- end
58
- end
59
- require_relative 'client/support'
60
- require_relative 'client/http_client'
61
- require_relative 'client/rack_test_client'