webspicy 0.19.0 → 0.20.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/bin/webspicy +1 -2
  3. data/lib/webspicy.rb +0 -2
  4. data/lib/webspicy/configuration.rb +15 -0
  5. data/lib/webspicy/configuration/scope.rb +1 -0
  6. data/lib/webspicy/specification.rb +4 -3
  7. data/lib/webspicy/specification/condition.rb +29 -4
  8. data/lib/webspicy/specification/err.rb +18 -0
  9. data/lib/webspicy/specification/oldies.rb +4 -0
  10. data/lib/webspicy/specification/oldies/bridge.rb +32 -0
  11. data/lib/webspicy/specification/{errcondition.rb → oldies/errcondition.rb} +5 -0
  12. data/lib/webspicy/specification/{postcondition.rb → oldies/postcondition.rb} +5 -0
  13. data/lib/webspicy/specification/{precondition.rb → oldies/precondition.rb} +5 -2
  14. data/lib/webspicy/specification/post.rb +20 -0
  15. data/lib/webspicy/specification/post/missing_condition_impl.rb +15 -0
  16. data/lib/webspicy/specification/post/unexpected_condition_impl.rb +15 -0
  17. data/lib/webspicy/specification/pre.rb +19 -0
  18. data/lib/webspicy/specification/{precondition → pre}/global_request_headers.rb +4 -4
  19. data/lib/webspicy/specification/{precondition → pre}/robust_to_invalid_input.rb +4 -4
  20. data/lib/webspicy/specification/service.rb +29 -5
  21. data/lib/webspicy/specification/test_case.rb +3 -0
  22. data/lib/webspicy/support.rb +12 -2
  23. data/lib/webspicy/support/colorize.rb +6 -0
  24. data/lib/webspicy/tester.rb +89 -27
  25. data/lib/webspicy/tester/assertions.rb +2 -2
  26. data/lib/webspicy/tester/client.rb +0 -26
  27. data/lib/webspicy/tester/fakeses.rb +41 -0
  28. data/lib/webspicy/tester/fakeses/email.rb +38 -0
  29. data/lib/webspicy/tester/fakesmtp.rb +39 -0
  30. data/lib/webspicy/tester/fakesmtp/email.rb +27 -0
  31. data/lib/webspicy/tester/reporter.rb +5 -0
  32. data/lib/webspicy/tester/reporter/documentation.rb +31 -8
  33. data/lib/webspicy/tester/reporter/error_count.rb +11 -7
  34. data/lib/webspicy/tester/reporter/exceptions.rb +2 -0
  35. data/lib/webspicy/tester/reporter/file_progress.rb +5 -2
  36. data/lib/webspicy/tester/reporter/file_summary.rb +3 -2
  37. data/lib/webspicy/tester/reporter/progress.rb +6 -4
  38. data/lib/webspicy/tester/reporter/summary.rb +9 -7
  39. data/lib/webspicy/tester/result.rb +16 -13
  40. data/lib/webspicy/tester/result/errcondition_met.rb +1 -3
  41. data/lib/webspicy/tester/result/error_schema_met.rb +1 -0
  42. data/lib/webspicy/tester/result/invocation_succeeded.rb +13 -0
  43. data/lib/webspicy/tester/result/output_schema_met.rb +1 -0
  44. data/lib/webspicy/tester/result/postcondition_met.rb +1 -3
  45. data/lib/webspicy/version.rb +2 -2
  46. data/lib/webspicy/web/invocation.rb +7 -3
  47. data/spec/blackbox/commandline.yml +24 -0
  48. data/spec/blackbox/fixtures/passing/config.rb +9 -0
  49. data/spec/blackbox/fixtures/passing/formaldef/get.yml +30 -0
  50. data/spec/unit/specification/{precondition → pre}/test_global_request_headers.rb +9 -4
  51. data/spec/unit/specification/test_condition.rb +18 -0
  52. data/spec/unit/tester/fakeses/test_email.rb +40 -0
  53. data/tasks/test.rake +2 -1
  54. metadata +34 -18
@@ -0,0 +1,9 @@
1
+ Webspicy::Configuration.new(Path.dir) do |c|
2
+ app = ->(env){
3
+ [ 200,
4
+ {"Content-Type" => "application/json"},
5
+ [ {hello: "World"}.to_json ]
6
+ ]
7
+ }
8
+ c.client = Webspicy::Tester::RackTestClient.for(app)
9
+ end
@@ -0,0 +1,30 @@
1
+ ---
2
+ url: |-
3
+ /
4
+
5
+ method: |-
6
+ GET
7
+
8
+ description: |-
9
+ Returns hello world
10
+
11
+ input_schema: |-
12
+ { }
13
+
14
+ output_schema: |-
15
+ { hello: String }
16
+
17
+ error_schema: |-
18
+ .
19
+
20
+ examples:
21
+
22
+ - description: |-
23
+ when requested
24
+ params: {}
25
+ expected:
26
+ content_type: application/json
27
+ status: 200
28
+ assert:
29
+ - notEmpty
30
+ - pathFD('', :hello => "World" )
@@ -2,16 +2,21 @@ require 'spec_helper'
2
2
 
3
3
  module Webspicy
4
4
  class Specification
5
- module Precondition
5
+ module Pre
6
6
  describe GlobalRequestHeaders do
7
7
  let(:gbr){
8
8
  GlobalRequestHeaders.new('Accept' => 'application/json')
9
9
  }
10
10
 
11
+ def instrument(tc)
12
+ t = OpenStruct.new(test_case: tc)
13
+ gbr.bind(t).instrument
14
+ end
15
+
11
16
  describe "instrument" do
12
17
  it 'injects the headers' do
13
18
  tc = TestCase.new({})
14
- gbr.instrument(tc, nil)
19
+ instrument(tc)
15
20
  expect(tc.headers['Accept']).to eql("application/json")
16
21
  end
17
22
 
@@ -21,7 +26,7 @@ module Webspicy
21
26
  'Content-Type' => 'text/plain'
22
27
  }
23
28
  })
24
- gbr.instrument(tc, nil)
29
+ instrument(tc)
25
30
  expect(tc.headers['Content-Type']).to eql("text/plain")
26
31
  expect(tc.headers['Accept']).to eql("application/json")
27
32
  end
@@ -32,7 +37,7 @@ module Webspicy
32
37
  'Accept' => 'text/plain'
33
38
  }
34
39
  })
35
- gbr.instrument(tc, nil)
40
+ instrument(tc)
36
41
  expect(tc.headers['Accept']).to eql("text/plain")
37
42
  end
38
43
  end
@@ -15,6 +15,24 @@ module Webspicy
15
15
  expect(x).to eql(nil)
16
16
  end
17
17
 
18
+ it 'supports the block raising a Failure' do
19
+ expect {
20
+ sooner_or_later(max: 2){
21
+ raise Tester::Failure
22
+ }
23
+ }.to raise_error(Tester::Failure)
24
+ end
25
+
26
+ it 'catches Failure occuring before successes' do
27
+ seen = 0
28
+ x = sooner_or_later(max: 2){
29
+ seen += 1
30
+ raise Tester::Failure if seen == 1
31
+ 12
32
+ }
33
+ expect(x).to eql(12)
34
+ end
35
+
18
36
  it 'can raise for us' do
19
37
  expect{
20
38
  sooner_or_later(max: 1, raise: true){ nil }
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+ require 'webspicy/tester/fakeses'
3
+ module Webspicy
4
+ class Tester
5
+ class Fakeses
6
+ describe Email do
7
+
8
+ DATA = Base64.encode64 <<~J
9
+ From: Webspicy <noreply@webspicy.io>
10
+ To: someone@world.com
11
+ Subject: Hey world, hello!
12
+ J
13
+
14
+ DATA = JSON.parse <<~J
15
+ {
16
+ "id": "1782605f-da34-9c02-6a38-d7e101029cbf",
17
+ "body": {
18
+ "Source": "noreply@webspicy.io",
19
+ "Destinations.member.1": "someone@world.com",
20
+ "RawMessage.Data": "#{DATA.gsub /\n/, ''}",
21
+ "Action": "SendRawEmail",
22
+ "Version": "2010-12-01"
23
+ }
24
+ }
25
+ J
26
+
27
+ subject{
28
+ Email.new(DATA)
29
+ }
30
+
31
+ it 'works as expected' do
32
+ expect(subject.from).to eql("noreply@webspicy.io")
33
+ expect(subject.to).to eql(["someone@world.com"])
34
+ expect(subject.subject).to eql("Hey world, hello!")
35
+ end
36
+
37
+ end
38
+ end
39
+ end
40
+ end
data/tasks/test.rake CHANGED
@@ -18,7 +18,8 @@ namespace :test do
18
18
  desc "Runs the integration tests on the #{file.basename} example"
19
19
  task(test_name) do
20
20
  Bundler.with_original_env do
21
- system("cd #{file} && bundle exec rake")
21
+ x = system("cd #{file} && bundle exec rake")
22
+ abort("Example test suite failed: #{file}") unless x
22
23
  end
23
24
  end
24
25
  tests << test_name
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.19.0
4
+ version: 0.20.4
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-03-09 00:00:00.000000000 Z
11
+ date: 2021-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -126,22 +126,22 @@ dependencies:
126
126
  name: rack-robustness
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: 1.1.0
132
129
  - - "~>"
133
130
  - !ruby/object:Gem::Version
134
131
  version: '1.1'
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: 1.1.0
135
135
  type: :runtime
136
136
  prerelease: false
137
137
  version_requirements: !ruby/object:Gem::Requirement
138
138
  requirements:
139
- - - ">="
140
- - !ruby/object:Gem::Version
141
- version: 1.1.0
142
139
  - - "~>"
143
140
  - !ruby/object:Gem::Version
144
141
  version: '1.1'
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: 1.1.0
145
145
  - !ruby/object:Gem::Dependency
146
146
  name: mustermann
147
147
  requirement: !ruby/object:Gem::Requirement
@@ -222,12 +222,19 @@ files:
222
222
  - lib/webspicy/formaldoc.fio
223
223
  - lib/webspicy/specification.rb
224
224
  - lib/webspicy/specification/condition.rb
225
- - lib/webspicy/specification/errcondition.rb
225
+ - lib/webspicy/specification/err.rb
226
226
  - lib/webspicy/specification/file_upload.rb
227
- - lib/webspicy/specification/postcondition.rb
228
- - lib/webspicy/specification/precondition.rb
229
- - lib/webspicy/specification/precondition/global_request_headers.rb
230
- - lib/webspicy/specification/precondition/robust_to_invalid_input.rb
227
+ - lib/webspicy/specification/oldies.rb
228
+ - lib/webspicy/specification/oldies/bridge.rb
229
+ - lib/webspicy/specification/oldies/errcondition.rb
230
+ - lib/webspicy/specification/oldies/postcondition.rb
231
+ - lib/webspicy/specification/oldies/precondition.rb
232
+ - lib/webspicy/specification/post.rb
233
+ - lib/webspicy/specification/post/missing_condition_impl.rb
234
+ - lib/webspicy/specification/post/unexpected_condition_impl.rb
235
+ - lib/webspicy/specification/pre.rb
236
+ - lib/webspicy/specification/pre/global_request_headers.rb
237
+ - lib/webspicy/specification/pre/robust_to_invalid_input.rb
231
238
  - lib/webspicy/specification/service.rb
232
239
  - lib/webspicy/specification/test_case.rb
233
240
  - lib/webspicy/support.rb
@@ -241,6 +248,10 @@ files:
241
248
  - lib/webspicy/tester/assertions.rb
242
249
  - lib/webspicy/tester/client.rb
243
250
  - lib/webspicy/tester/failure.rb
251
+ - lib/webspicy/tester/fakeses.rb
252
+ - lib/webspicy/tester/fakeses/email.rb
253
+ - lib/webspicy/tester/fakesmtp.rb
254
+ - lib/webspicy/tester/fakesmtp/email.rb
244
255
  - lib/webspicy/tester/file_checker.rb
245
256
  - lib/webspicy/tester/invocation.rb
246
257
  - lib/webspicy/tester/reporter.rb
@@ -257,6 +268,7 @@ files:
257
268
  - lib/webspicy/tester/result/check.rb
258
269
  - lib/webspicy/tester/result/errcondition_met.rb
259
270
  - lib/webspicy/tester/result/error_schema_met.rb
271
+ - lib/webspicy/tester/result/invocation_succeeded.rb
260
272
  - lib/webspicy/tester/result/output_schema_met.rb
261
273
  - lib/webspicy/tester/result/postcondition_met.rb
262
274
  - lib/webspicy/tester/result/response_header_met.rb
@@ -272,13 +284,16 @@ files:
272
284
  - lib/webspicy/web/mocker/config.ru
273
285
  - lib/webspicy/web/openapi.rb
274
286
  - lib/webspicy/web/openapi/generator.rb
287
+ - spec/blackbox/commandline.yml
288
+ - spec/blackbox/fixtures/passing/config.rb
289
+ - spec/blackbox/fixtures/passing/formaldef/get.yml
275
290
  - spec/spec_helper.rb
276
291
  - spec/unit/configuration/config.rb
277
292
  - spec/unit/configuration/scope/test_each_service.rb
278
293
  - spec/unit/configuration/scope/test_each_specification.rb
279
294
  - spec/unit/configuration/scope/test_expand_example.rb
280
295
  - spec/unit/configuration/scope/test_to_real_url.rb
281
- - spec/unit/specification/precondition/test_global_request_headers.rb
296
+ - spec/unit/specification/pre/test_global_request_headers.rb
282
297
  - spec/unit/specification/service/test_dress_params.rb
283
298
  - spec/unit/specification/test_case/test_mutate.rb
284
299
  - spec/unit/specification/test_condition.rb
@@ -294,6 +309,7 @@ files:
294
309
  - spec/unit/support/world/fixtures/yaml.yml
295
310
  - spec/unit/support/world/test_world.rb
296
311
  - spec/unit/test_configuration.rb
312
+ - spec/unit/tester/fakeses/test_email.rb
297
313
  - spec/unit/tester/test_asserter.rb
298
314
  - spec/unit/tester/test_assertions.rb
299
315
  - spec/unit/web/mocker/test_mocker.rb
@@ -304,7 +320,7 @@ homepage: http://github.com/enspirit/webspicy
304
320
  licenses:
305
321
  - MIT
306
322
  metadata: {}
307
- post_install_message:
323
+ post_install_message:
308
324
  rdoc_options: []
309
325
  require_paths:
310
326
  - lib
@@ -319,8 +335,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
319
335
  - !ruby/object:Gem::Version
320
336
  version: '0'
321
337
  requirements: []
322
- rubygems_version: 3.0.8
323
- signing_key:
338
+ rubygems_version: 3.1.4
339
+ signing_key:
324
340
  specification_version: 4
325
341
  summary: Webspicy helps testing web services as software operation black boxes!
326
342
  test_files: []