webspicy 0.20.8 → 0.20.9

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: 9f14b3463098780f10139ffd28362d60eaa61e4b9e77d16a91e8ac597847ca1b
4
- data.tar.gz: 73571e1c2bd2764e4de2af708fa94d396ae943029ab11300ce9e14345c3479db
3
+ metadata.gz: 0bdf5cfac3023b3a121368cd16c4b36df8cc212b6093672c836fbb2c392e5d68
4
+ data.tar.gz: 3506d6e9ec23a6d21299dcabf2564b1d643a49cf58ba853d6263763838d8efe7
5
5
  SHA512:
6
- metadata.gz: 3e6281472272c61b01898ff513b721a3203a6c21ad314c0932d069fab01529d060030db1d0a0d6bb445bf306a62618227aee1fd6dfaea08f0073247f338b9582
7
- data.tar.gz: 7136d69f3f9b5de2a1fb72a37377bc01262311c9f4e6bbf52e2062452368a5b81ace3f11b9173c88ac85f46ea3c2765582633b8cb22a43d85def530fb378c471
6
+ metadata.gz: 4c84f0fde9c02350d61969503fd93fa139dc2b39bd377f800597adfae760bfb60b25a83894bac2642b75029c67963a3293a463eed4c00eb85491920a8bd53af4
7
+ data.tar.gz: f215620b9e9a0b7346c09b1ef1a1d1e3acac1f28f57df64ea0864156ceb9e9a7a888bddb4b67462255efc1a15f9860af368fbe510f148ea09871526e90da79fa
@@ -14,6 +14,10 @@ module Webspicy
14
14
  @location = Path(location)
15
15
  end
16
16
 
17
+ def relative_location
18
+ @location && @location.relative_to(config.folder)
19
+ end
20
+
17
21
  def locate(relative_path)
18
22
  file = @location.parent/relative_path
19
23
  raise "File not found: #{file}" unless file.exists?
@@ -21,7 +25,7 @@ module Webspicy
21
25
  end
22
26
 
23
27
  def name
24
- @raw[:name]
28
+ @raw[:name] || relative_location || "Unnamed"
25
29
  end
26
30
 
27
31
  def services
@@ -149,6 +149,8 @@ module Webspicy
149
149
  end
150
150
 
151
151
  def call_test_case_target
152
+ @invocation = nil
153
+ @invocation_error = nil
152
154
  reporter.before_invocation
153
155
  @invocation = client.call(test_case)
154
156
  reporter.invocation_done
@@ -88,3 +88,4 @@ require_relative 'reporter/composite'
88
88
  require_relative 'reporter/file_progress'
89
89
  require_relative 'reporter/file_summary'
90
90
  require_relative 'reporter/success_or_not'
91
+ require_relative 'reporter/junit_xml_file'
@@ -15,7 +15,7 @@ module Webspicy
15
15
  @spec_file_errors << spec_file_error_line(spec_file, e)
16
16
  end
17
17
 
18
- def after_each_done
18
+ def test_case_done
19
19
  @failed_results << result unless result.success?
20
20
  end
21
21
 
@@ -24,6 +24,8 @@ module Webspicy
24
24
  report_failed_results
25
25
  end
26
26
 
27
+ private
28
+
27
29
  def report_spec_file_errors
28
30
  return if spec_file_errors.empty?
29
31
  io.puts
@@ -0,0 +1,151 @@
1
+ module Webspicy
2
+ class Tester
3
+ class Reporter
4
+ class JunitXmlFile < Reporter
5
+
6
+ TPL = <<~XML
7
+ <?xml version="1.0" encoding="UTF-8"?>
8
+ <testsuites
9
+ disabled="{{counts.disabled}}"
10
+ errors="{{counts.errors}}"
11
+ failures="{{counts.failures}}"
12
+ tests="{{counts.total}}"
13
+ time="{{time}}s"
14
+ >
15
+ {{#testsuites}}
16
+ <testsuite
17
+ name="{{name}}"
18
+ tests="{{counts.total}}"
19
+ errors="{{counts.errors}}"
20
+ failures="{{counts.failures}}"
21
+ time="{{time}}s"
22
+ >
23
+ {{#testcases}}
24
+ <testcase
25
+ name="{{name}}"
26
+ assertions="{{assert}}"
27
+ classname="{{classname}}"
28
+ status=""
29
+ time="{{time}}s"
30
+ >
31
+ {{#errors}}
32
+ <error
33
+ message="{{message}}"
34
+ type="{{type}}"
35
+ ></error>
36
+ {{/errors}}
37
+ {{#failures}}
38
+ <failure
39
+ message="{{message}}"
40
+ type="{{type}}"
41
+ ></failure>
42
+ {{/failures}}
43
+ </testcase>
44
+ {{/testcases}}
45
+ </testsuite>
46
+ {{/testsuites}}
47
+ </testsuites>
48
+ XML
49
+
50
+ def initialize(path_or_io = STDOUT)
51
+ @path_or_io = path_or_io
52
+ path_or_io.parent.mkdir_p if path_or_io.is_a?(Path)
53
+ end
54
+
55
+ attr_reader :template_data, :timer_all, :timer_specification, :timer_testcase
56
+
57
+ def before_all
58
+ @timer_all = Time.now
59
+ @template_data = OpenStruct.new({
60
+ counts: Hash.new{|h,k| h[k] = 0 },
61
+ testsuites: []
62
+ })
63
+ end
64
+
65
+ def after_all
66
+ template_data.time = Time.now - timer_all
67
+ end
68
+
69
+ def before_specification
70
+ @timer_specification = Time.now
71
+ template_data.testsuites << OpenStruct.new({
72
+ :name => specification.name,
73
+ :counts => Hash.new{|h,k| h[k] = 0 },
74
+ :testcases => []
75
+ })
76
+ end
77
+
78
+ def specification_done
79
+ template_data.testsuites[-1].time = Time.now - timer_specification
80
+ end
81
+
82
+ def spec_file_error(e)
83
+ template_data.testsuites[-1].testcases << OpenStruct.new({
84
+ :name => "Specification can be loaded",
85
+ :assert => 1,
86
+ :classname => "Webspicy.Specification",
87
+ :failures => [],
88
+ :errors => [OpenStruct.new({
89
+ :type => e.class,
90
+ :message => e.message
91
+ })]
92
+ })
93
+ end
94
+
95
+ def before_test_case
96
+ @timer_testcase = Time.now
97
+ template_data.testsuites[-1].testcases << OpenStruct.new({
98
+ :name => test_case.description,
99
+ :assert => test_case.assert.length,
100
+ :classname => test_case.class.name.to_s.gsub(/::/, "."),
101
+ :failures => [],
102
+ :errors => [],
103
+ })
104
+ template_data.counts[:total] += 1
105
+ template_data.testsuites[-1].counts[:total] += 1
106
+ end
107
+
108
+ def test_case_done
109
+ template_data.testsuites[-1].testcases[-1].time = Time.now - timer_testcase
110
+ end
111
+
112
+ def check_failure(check, ex)
113
+ template_data.testsuites[-1].testcases[-1].failures << OpenStruct.new({
114
+ :type => check.class.name,
115
+ :message => ex.message
116
+ })
117
+ template_data.counts[:failures] += 1
118
+ template_data.testsuites[-1].counts[:failures] += 1
119
+ end
120
+
121
+ def check_error(check, ex)
122
+ template_data.testsuites[-1].testcases[-1].errors << OpenStruct.new({
123
+ :type => check.class.name,
124
+ :message => ex.message
125
+ })
126
+ template_data.counts[:errors] += 1
127
+ template_data.testsuites[-1].counts[:errors] += 1
128
+ end
129
+
130
+ def report
131
+ require 'mustache'
132
+ with_io do |io|
133
+ io << Mustache.render(TPL, template_data)
134
+ end
135
+ end
136
+
137
+ private
138
+
139
+ def with_io(&bl)
140
+ case io = @path_or_io
141
+ when IO, StringIO
142
+ bl.call(io)
143
+ else
144
+ Path(io).open('w', &bl)
145
+ end
146
+ end
147
+
148
+ end # class JunitXmlFile
149
+ end # class Reporter
150
+ end # class Tester
151
+ end # module Webspicy
@@ -7,7 +7,7 @@ module Webspicy
7
7
  io.print colorize_error("X", config)
8
8
  end
9
9
 
10
- def after_each_done
10
+ def test_case_done
11
11
  if result.success?
12
12
  io.print colorize_success(".", config)
13
13
  elsif result.failure?
@@ -26,7 +26,7 @@ module Webspicy
26
26
  @spec_file_errors_count += 1
27
27
  end
28
28
 
29
- def after_each_done
29
+ def test_case_done
30
30
  if tester.test_case.counterexample?
31
31
  @counterexamples_count += 1
32
32
  else
@@ -18,6 +18,7 @@ module Webspicy
18
18
  check!
19
19
  else
20
20
  @errors << [InvocationSuceeded.new(self), tester.invocation_error]
21
+ reporter.check_error(*errors.first)
21
22
  end
22
23
  end
23
24
  attr_reader :tester, :scope, :client
@@ -2,7 +2,7 @@ module Webspicy
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 20
5
- TINY = 8
5
+ TINY = 9
6
6
  end
7
7
  VERSION = "#{Version::MAJOR}.#{Version::MINOR}.#{Version::TINY}"
8
8
  end
@@ -9,7 +9,7 @@ module Webspicy
9
9
 
10
10
  def singleservice(raw)
11
11
  converted = {
12
- name: raw[:name] || "Unamed specification",
12
+ name: raw[:name],
13
13
  url: raw[:url],
14
14
  services: [
15
15
  Webspicy::Web.service(raw.reject{|k| k==:url or k==:name }, Webspicy.current_scope)
data/tasks/test.rake CHANGED
@@ -5,8 +5,12 @@ namespace :test do
5
5
 
6
6
  desc "Runs unit tests on the library itself"
7
7
  RSpec::Core::RakeTask.new(:unit) do |t|
8
+ require 'path'
9
+ root_folder = Path.dir.parent
10
+ test_results = root_folder/"test-results"
11
+ puts (test_results/"unit-tests.xml").inspect
8
12
  t.pattern = "spec/unit/**/test_*.rb"
9
- t.rspec_opts = ["-Ilib", "-Ispec/unit", "--color", "--backtrace", "--format=progress"]
13
+ t.rspec_opts = ["-Ilib", "-Ispec/unit", "--color", "--backtrace", "--format=progress", "--format RspecJunitFormatter", "--out #{test_results}/unit-tests.xml"]
10
14
  end
11
15
  tests << :unit
12
16
 
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.8
4
+ version: 0.20.9
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-04-28 00:00:00.000000000 Z
11
+ date: 2021-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -198,11 +198,23 @@ dependencies:
198
198
  - - "~>"
199
199
  - !ruby/object:Gem::Version
200
200
  version: 0.8.2
201
+ - !ruby/object:Gem::Dependency
202
+ name: mustache
203
+ requirement: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - "~>"
206
+ - !ruby/object:Gem::Version
207
+ version: '1.0'
208
+ type: :runtime
209
+ prerelease: false
210
+ version_requirements: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - "~>"
213
+ - !ruby/object:Gem::Version
214
+ version: '1.0'
201
215
  description: Webspicy helps testing web services as software operation black boxes
202
216
  email: blambeau@gmail.com
203
217
  executables:
204
- - sandr
205
- - search
206
218
  - webspicy
207
219
  extensions: []
208
220
  extra_rdoc_files: []
@@ -210,8 +222,6 @@ files:
210
222
  - Gemfile
211
223
  - README.md
212
224
  - Rakefile
213
- - bin/sandr
214
- - bin/search
215
225
  - bin/webspicy
216
226
  - doc/1-black-box-scene.md
217
227
  - doc/2-black-box-testing.md
@@ -263,6 +273,7 @@ files:
263
273
  - lib/webspicy/tester/reporter/exceptions.rb
264
274
  - lib/webspicy/tester/reporter/file_progress.rb
265
275
  - lib/webspicy/tester/reporter/file_summary.rb
276
+ - lib/webspicy/tester/reporter/junit_xml_file.rb
266
277
  - lib/webspicy/tester/reporter/progress.rb
267
278
  - lib/webspicy/tester/reporter/success_or_not.rb
268
279
  - lib/webspicy/tester/reporter/summary.rb
@@ -326,7 +337,7 @@ homepage: http://github.com/enspirit/webspicy
326
337
  licenses:
327
338
  - MIT
328
339
  metadata: {}
329
- post_install_message:
340
+ post_install_message:
330
341
  rdoc_options: []
331
342
  require_paths:
332
343
  - lib
@@ -341,8 +352,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
341
352
  - !ruby/object:Gem::Version
342
353
  version: '0'
343
354
  requirements: []
344
- rubygems_version: 3.0.1
345
- signing_key:
355
+ rubygems_version: 3.0.8
356
+ signing_key:
346
357
  specification_version: 4
347
358
  summary: Webspicy helps testing web services as software operation black boxes!
348
359
  test_files: []
data/bin/sandr DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'path'
3
-
4
- def sandr(file)
5
- file.write file.read.gsub(ARGV[0], ARGV[1])
6
- end
7
-
8
- Path.dir.parent.glob("lib/**/*.rb") do |file|
9
- sandr(file)
10
- end
11
-
12
- Path.dir.parent.glob("spec/**/*.rb") do |file|
13
- sandr(file)
14
- end
data/bin/search DELETED
@@ -1,2 +0,0 @@
1
- #!/bin/bash
2
- grep -Rn --color $1 lib spec