spectre-core 1.12.4 → 1.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/spectre +31 -24
- data/lib/spectre/assertion.rb +38 -38
- data/lib/spectre/async.rb +31 -0
- data/lib/spectre/bag.rb +1 -1
- data/lib/spectre/curl.rb +4 -6
- data/lib/spectre/helpers.rb +4 -0
- data/lib/spectre/http/keystone.rb +0 -2
- data/lib/spectre/http.rb +25 -6
- data/lib/spectre/logger/console.rb +1 -1
- data/lib/spectre/logger/file.rb +19 -19
- data/lib/spectre/logger.rb +37 -10
- data/lib/spectre/mixin.rb +3 -3
- data/lib/spectre/reporter/console.rb +19 -22
- data/lib/spectre/reporter/html.rb +1167 -0
- data/lib/spectre/reporter/junit.rb +24 -21
- data/lib/spectre/reporter/vstest.rb +167 -0
- data/lib/spectre.rb +78 -61
- data/resources/OpenSans-Regular.ttf +0 -0
- data/resources/fa-regular-400.ttf +0 -0
- data/resources/fa-solid-900.ttf +0 -0
- data/resources/spectre_icon.svg +106 -0
- data/resources/vue.global.prod.js +1 -0
- metadata +13 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd2c5dd03f2ded27246d351696a749bf0f0fbb06ff87ecc27363873202ecb1ac
|
4
|
+
data.tar.gz: a17d75c2581c6f64f58664b78c68449936610f8fa9c6c313dc73011da59094c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 941692c923f0437410ad99376a1df249c81dd970c527445e9a4e3721554e35e2f6d10cca4f23293894df212f7bd5dc4b36ab1610b3351919a88dc9a6fdd8cd18
|
7
|
+
data.tar.gz: 7245b35708dc29ee1c0d2ec60ec10cbd39125f7302aa3e84962037e2e30824793290b59f70c51e8a7892d79780747697f8635c90b48e3ba4d2276015538bb8b3
|
data/exe/spectre
CHANGED
@@ -16,6 +16,7 @@ end
|
|
16
16
|
|
17
17
|
|
18
18
|
DEFAULT_CONFIG = {
|
19
|
+
'project' => nil,
|
19
20
|
'config_file' => './spectre.yml',
|
20
21
|
'environment' => 'default',
|
21
22
|
'specs' => [],
|
@@ -26,8 +27,8 @@ DEFAULT_CONFIG = {
|
|
26
27
|
'Spectre::Reporter::Console',
|
27
28
|
],
|
28
29
|
'loggers' => [
|
29
|
-
'Spectre::
|
30
|
-
'Spectre::
|
30
|
+
'Spectre::Logging::Console',
|
31
|
+
'Spectre::Logging::File',
|
31
32
|
],
|
32
33
|
'log_file' => './logs/spectre_<date>.log',
|
33
34
|
'log_format' => {
|
@@ -55,6 +56,8 @@ DEFAULT_CONFIG = {
|
|
55
56
|
'spectre/helpers',
|
56
57
|
'spectre/reporter/console',
|
57
58
|
'spectre/reporter/junit',
|
59
|
+
'spectre/reporter/vstest',
|
60
|
+
'spectre/reporter/html',
|
58
61
|
'spectre/logger/console',
|
59
62
|
'spectre/logger/file',
|
60
63
|
'spectre/assertion',
|
@@ -66,6 +69,7 @@ DEFAULT_CONFIG = {
|
|
66
69
|
'spectre/http/basic_auth',
|
67
70
|
'spectre/http/keystone',
|
68
71
|
'spectre/resources',
|
72
|
+
'spectre/async',
|
69
73
|
],
|
70
74
|
'include' => [
|
71
75
|
|
@@ -79,20 +83,22 @@ DEFAULT_CONFIG = {
|
|
79
83
|
cmd_options = {}
|
80
84
|
property_overrides = {}
|
81
85
|
|
82
|
-
|
83
|
-
opts.banner = %{Spectre #{Spectre::VERSION}
|
86
|
+
$COMMAND = ['spectre'].concat(ARGV.clone).join(' ')
|
84
87
|
|
85
|
-
|
88
|
+
OptionParser.new do |opts|
|
89
|
+
opts.banner = %{Spectre #{Spectre::VERSION}
|
86
90
|
|
87
|
-
|
88
|
-
list List specs
|
89
|
-
run Run specs (default)
|
90
|
-
show Print current environment settings
|
91
|
-
dump Dumps the given environment in YAML format to console
|
92
|
-
cleanup Will remove all generated files (e.g. logs and reports)
|
93
|
-
init Initializes a new spectre project
|
91
|
+
Usage: spectre [command] [options]
|
94
92
|
|
95
|
-
|
93
|
+
Commands:
|
94
|
+
list List specs
|
95
|
+
run Run specs (default)
|
96
|
+
show Print current environment settings
|
97
|
+
dump Dumps the given environment in YAML format to console
|
98
|
+
cleanup Will remove all generated files (e.g. logs and reports)
|
99
|
+
init Initializes a new spectre project
|
100
|
+
|
101
|
+
Specific options:}
|
96
102
|
|
97
103
|
opts.on('-s SPEC,SPEC', '--specs SPEC,SPEC', Array, 'The specs to run') do |specs|
|
98
104
|
cmd_options['specs'] = specs
|
@@ -199,6 +205,8 @@ if File.exists? config_file
|
|
199
205
|
Dir.chdir File.dirname(config_file)
|
200
206
|
end
|
201
207
|
|
208
|
+
cfg['project'] = File.basename(Dir.pwd) unless cfg['project']
|
209
|
+
|
202
210
|
cfg.deep_merge! cmd_options
|
203
211
|
|
204
212
|
###########################################
|
@@ -300,16 +308,15 @@ if 'run' == action
|
|
300
308
|
# Initialize logger
|
301
309
|
now = Time.now
|
302
310
|
|
303
|
-
cfg['log_file'] = cfg['log_file'].frmt(
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
})
|
311
|
+
cfg['log_file'] = cfg['log_file'].frmt({
|
312
|
+
shortdate: now.strftime('%Y-%m-%d'),
|
313
|
+
date: now.strftime('%Y-%m-%d_%H%M%S'),
|
314
|
+
timestamp: now.strftime('%s'),
|
315
|
+
subject: 'spectre',
|
316
|
+
})
|
310
317
|
|
311
|
-
log_dir = File.dirname
|
312
|
-
FileUtils.makedirs
|
318
|
+
log_dir = File.dirname(cfg['log_file'])
|
319
|
+
FileUtils.makedirs(log_dir)
|
313
320
|
|
314
321
|
# Load Modules
|
315
322
|
|
@@ -346,11 +353,11 @@ if 'run' == action
|
|
346
353
|
|
347
354
|
Spectre.configure(cfg)
|
348
355
|
|
349
|
-
Spectre::
|
356
|
+
Spectre::Logging.debug! if cfg['debug']
|
350
357
|
|
351
358
|
cfg['loggers'].each do |logger_name|
|
352
359
|
logger = Kernel.const_get(logger_name).new(cfg)
|
353
|
-
Spectre::
|
360
|
+
Spectre::Logging.add(logger)
|
354
361
|
end if cfg['loggers']
|
355
362
|
|
356
363
|
specs = Spectre.specs(cfg['specs'], cfg['tags'])
|
data/lib/spectre/assertion.rb
CHANGED
@@ -8,23 +8,23 @@ module Spectre
|
|
8
8
|
module Assertion
|
9
9
|
class ::Object
|
10
10
|
def should_be(val)
|
11
|
-
raise AssertionFailure.new("
|
11
|
+
raise AssertionFailure.new("'#{self.to_s.trim}' should be '#{val.to_s.trim}'", val, self) unless self.to_s == val.to_s
|
12
12
|
end
|
13
13
|
|
14
14
|
def should_be_empty
|
15
|
-
raise AssertionFailure.new("
|
15
|
+
raise AssertionFailure.new("'#{self.to_s.trim}' should be empty", nil, self) unless self.nil?
|
16
16
|
end
|
17
17
|
|
18
18
|
def should_not_be(val)
|
19
|
-
raise AssertionFailure.new("
|
19
|
+
raise AssertionFailure.new("'#{self.to_s.trim}' should not be '#{val.to_s.trim}'", val, self) unless self.to_s != val.to_s
|
20
20
|
end
|
21
21
|
|
22
22
|
def should_not_exist
|
23
|
-
raise AssertionFailure.new("
|
23
|
+
raise AssertionFailure.new("'#{self.to_s.trim}' should not exist, but it does", val, self) unless self.to_s != nil
|
24
24
|
end
|
25
25
|
|
26
26
|
def should_not_be_empty
|
27
|
-
raise AssertionFailure.new('
|
27
|
+
raise AssertionFailure.new('empty value', 'nothing', self) unless self != nil
|
28
28
|
end
|
29
29
|
|
30
30
|
def or other
|
@@ -38,7 +38,7 @@ module Spectre
|
|
38
38
|
|
39
39
|
class ::NilClass
|
40
40
|
def should_be(val)
|
41
|
-
raise AssertionFailure.new("
|
41
|
+
raise AssertionFailure.new("Value is empty, but it should be '#{val.to_s.trim}'", val, nil) unless val == nil
|
42
42
|
end
|
43
43
|
|
44
44
|
def should_be_empty
|
@@ -52,7 +52,7 @@ module Spectre
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def should_not_be_empty
|
55
|
-
raise AssertionFailure.new('
|
55
|
+
raise AssertionFailure.new('Value is empty', 'nil')
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -66,21 +66,21 @@ module Spectre
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def should_be_empty
|
69
|
-
raise AssertionFailure.new('
|
69
|
+
raise AssertionFailure.new('Object should be empty', nil, self) unless self.empty?
|
70
70
|
end
|
71
71
|
|
72
72
|
def should_not_be_empty
|
73
|
-
raise AssertionFailure.new('
|
73
|
+
raise AssertionFailure.new('Object should not be empty', nil, self) if self.empty?
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
77
|
class ::OpenStruct
|
78
78
|
def should_be_empty
|
79
|
-
raise AssertionFailure.new('
|
79
|
+
raise AssertionFailure.new('Object should be empty', nil, self) unless self.to_h.empty?
|
80
80
|
end
|
81
81
|
|
82
82
|
def should_not_be_empty
|
83
|
-
raise AssertionFailure.new('
|
83
|
+
raise AssertionFailure.new('Object should not be empty', nil, self) if self.to_h.empty?
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
@@ -93,7 +93,7 @@ module Spectre
|
|
93
93
|
val = OpenStruct.new(val)
|
94
94
|
end
|
95
95
|
|
96
|
-
raise AssertionFailure.new("
|
96
|
+
raise AssertionFailure.new("[#{list.join(', ').trim}] should contain '#{val.to_s.trim}'", val, list) unless list.include? val
|
97
97
|
end
|
98
98
|
|
99
99
|
def should_not_contain(val)
|
@@ -104,37 +104,37 @@ module Spectre
|
|
104
104
|
val = OpenStruct.new(val)
|
105
105
|
end
|
106
106
|
|
107
|
-
raise AssertionFailure.new("
|
107
|
+
raise AssertionFailure.new("[#{list.join(', ').trim}] should not contain '#{val.to_s.trim}'", val, list) if list.include? val
|
108
108
|
end
|
109
109
|
|
110
110
|
def should_be_empty
|
111
|
-
raise AssertionFailure.new('
|
111
|
+
raise AssertionFailure.new('List is not empty', self) unless self.empty?
|
112
112
|
end
|
113
113
|
|
114
114
|
def should_not_be_empty
|
115
|
-
raise AssertionFailure.new('
|
115
|
+
raise AssertionFailure.new('List is empty', self) if self.empty?
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
119
|
class ::String
|
120
120
|
def should_be(val)
|
121
|
-
raise AssertionFailure.new("
|
121
|
+
raise AssertionFailure.new("'#{self.trim}' should be '#{val.to_s.trim}'", val, self) unless self == val
|
122
122
|
end
|
123
123
|
|
124
124
|
def should_be_empty
|
125
|
-
raise AssertionFailure.new("
|
125
|
+
raise AssertionFailure.new("'#{self.trim}' should be empty", nil, self) unless self.empty?
|
126
126
|
end
|
127
127
|
|
128
128
|
def should_not_be(val)
|
129
|
-
raise AssertionFailure.new("
|
129
|
+
raise AssertionFailure.new("'#{self.trim}' should not be '#{val.to_s.trim}'", val, self) unless self != val
|
130
130
|
end
|
131
131
|
|
132
132
|
def should_not_be_empty
|
133
|
-
raise AssertionFailure.new('
|
133
|
+
raise AssertionFailure.new('Text should not be empty', 'nothing', self) unless not self.empty?
|
134
134
|
end
|
135
135
|
|
136
136
|
def should_contain(value)
|
137
|
-
raise AssertionFailure.new("
|
137
|
+
raise AssertionFailure.new("Value is nil") if value.nil?
|
138
138
|
|
139
139
|
predicate = proc { |x| self.include? x.to_s }
|
140
140
|
evaluation = SingleEvaluation.new(value)
|
@@ -142,19 +142,19 @@ module Spectre
|
|
142
142
|
|
143
143
|
return if success
|
144
144
|
|
145
|
-
raise AssertionFailure.new("
|
145
|
+
raise AssertionFailure.new("'#{self.to_s.trim}' should contain #{evaluation.to_s}", evaluation, self)
|
146
146
|
end
|
147
147
|
|
148
148
|
def should_not_contain(val)
|
149
|
-
raise AssertionFailure.new("
|
149
|
+
raise AssertionFailure.new("'#{self.trim}' should not contain '#{val.trim}'", val, self) if self.include? val
|
150
150
|
end
|
151
151
|
|
152
152
|
def should_match(regex)
|
153
|
-
raise AssertionFailure.new("
|
153
|
+
raise AssertionFailure.new("'#{self.trim}' should match '#{val}'", regex, self) unless self.match(regex)
|
154
154
|
end
|
155
155
|
|
156
156
|
def should_not_match(regex)
|
157
|
-
raise AssertionFailure.new("
|
157
|
+
raise AssertionFailure.new("'#{self.trim}' should not match '#{val}'", regex, self) if self.match(regex)
|
158
158
|
end
|
159
159
|
|
160
160
|
alias :| :or
|
@@ -194,10 +194,6 @@ module Spectre
|
|
194
194
|
end
|
195
195
|
|
196
196
|
class OrEvaluation < Evaluation
|
197
|
-
def initialize value, other
|
198
|
-
super(value, other)
|
199
|
-
end
|
200
|
-
|
201
197
|
def call predicate
|
202
198
|
eval_assertion(predicate, @value) or eval_assertion(predicate, @other)
|
203
199
|
end
|
@@ -208,10 +204,6 @@ module Spectre
|
|
208
204
|
end
|
209
205
|
|
210
206
|
class AndEvaluation < Evaluation
|
211
|
-
def initialize value, other
|
212
|
-
super(value, other)
|
213
|
-
end
|
214
|
-
|
215
207
|
def call predicate
|
216
208
|
eval_assertion(predicate, @value) and eval_assertion(predicate, @other)
|
217
209
|
end
|
@@ -236,18 +228,26 @@ module Spectre
|
|
236
228
|
@@success = nil
|
237
229
|
|
238
230
|
def expect desc
|
231
|
+
status = 'unknown'
|
232
|
+
|
239
233
|
begin
|
240
|
-
|
234
|
+
Logging.log_process("expect #{desc}")
|
241
235
|
yield
|
242
|
-
|
236
|
+
Logging.log_status(desc, Logging::Status::OK)
|
237
|
+
status = 'ok'
|
243
238
|
rescue Interrupt => e
|
239
|
+
status = 'skipped'
|
244
240
|
raise e
|
245
241
|
rescue AssertionFailure => e
|
246
|
-
|
242
|
+
Logging.log_status(desc, Logging::Status::FAILED)
|
243
|
+
status = 'failed'
|
247
244
|
raise AssertionFailure.new(e.message, e.expected, e.actual, desc), cause: nil
|
248
245
|
rescue Exception => e
|
249
|
-
|
246
|
+
Logging.log_status(desc, Logging::Status::ERROR)
|
247
|
+
status = 'error'
|
250
248
|
raise AssertionFailure.new("An unexpected error occurred during expectation: #{e.message}", nil, nil, desc), cause: e
|
249
|
+
ensure
|
250
|
+
Spectre::Runner.current.expectations.append([desc, status])
|
251
251
|
end
|
252
252
|
end
|
253
253
|
|
@@ -256,7 +256,7 @@ module Spectre
|
|
256
256
|
prefix += " '#{desc}'" if desc
|
257
257
|
|
258
258
|
begin
|
259
|
-
|
259
|
+
Logging.log_info(prefix) if desc
|
260
260
|
yield
|
261
261
|
@@success = true
|
262
262
|
@@logger.info("#{prefix} finished with success")
|
@@ -281,7 +281,7 @@ module Spectre
|
|
281
281
|
end
|
282
282
|
|
283
283
|
Spectre.register do |config|
|
284
|
-
@@logger = ::
|
284
|
+
@@logger = Spectre::Logging::ModuleLogger.new(config, 'spectre/assertion')
|
285
285
|
@@debug = config['debug']
|
286
286
|
end
|
287
287
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative '../spectre'
|
2
|
+
|
3
|
+
Thread.abort_on_exception = true
|
4
|
+
|
5
|
+
module Spectre
|
6
|
+
module Async
|
7
|
+
class << self
|
8
|
+
@@threads = {}
|
9
|
+
|
10
|
+
def async name='default', &block
|
11
|
+
unless @@threads.key? name
|
12
|
+
@@threads[name] = []
|
13
|
+
end
|
14
|
+
|
15
|
+
@@threads[name] << Thread.new(&block)
|
16
|
+
end
|
17
|
+
|
18
|
+
def await name='default'
|
19
|
+
return unless @@threads.key? name
|
20
|
+
|
21
|
+
threads = @@threads[name].map { |x| x.join() }
|
22
|
+
|
23
|
+
@@threads.delete(name)
|
24
|
+
|
25
|
+
threads.map { |x| x.value }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
Spectre.delegate :async, :await, to: self
|
30
|
+
end
|
31
|
+
end
|
data/lib/spectre/bag.rb
CHANGED
data/lib/spectre/curl.rb
CHANGED
@@ -310,7 +310,7 @@ module Spectre::Curl
|
|
310
310
|
|
311
311
|
start_time = Time.now
|
312
312
|
|
313
|
-
|
313
|
+
_, stdout, stderr, wait_thr = Open3.popen3(sys_cmd)
|
314
314
|
|
315
315
|
end_time = Time.now
|
316
316
|
|
@@ -359,8 +359,8 @@ module Spectre::Curl
|
|
359
359
|
end
|
360
360
|
|
361
361
|
res_log = "[<] #{req_id} #{res[:code]} #{res[:message]} (#{end_time - start_time}s)\n"
|
362
|
-
res_headers.each do |
|
363
|
-
res_log += "#{
|
362
|
+
res_headers.each do |http_header|
|
363
|
+
res_log += "#{http_header[0].to_s.ljust(30, '.')}: #{http_header[1].to_s}\n"
|
364
364
|
end
|
365
365
|
|
366
366
|
if res[:body] != nil and not res[:body].empty?
|
@@ -380,11 +380,9 @@ module Spectre::Curl
|
|
380
380
|
Spectre.register do |config|
|
381
381
|
@@debug = config['debug']
|
382
382
|
|
383
|
-
@@logger = ::
|
384
|
-
@@logger.level = @@debug ? Logger::DEBUG : Logger::INFO
|
383
|
+
@@logger = Spectre::Logging::ModuleLogger.new(config, 'spectre/curl')
|
385
384
|
|
386
385
|
@@secure_keys = config['secure_keys'] || []
|
387
|
-
|
388
386
|
@@curl_path = config['curl_path'] || 'curl'
|
389
387
|
|
390
388
|
if config.key? 'http'
|
data/lib/spectre/helpers.rb
CHANGED
data/lib/spectre/http.rb
CHANGED
@@ -27,9 +27,6 @@ module Spectre
|
|
27
27
|
@@modules = []
|
28
28
|
|
29
29
|
class HttpError < Exception
|
30
|
-
def initialize message
|
31
|
-
super message
|
32
|
-
end
|
33
30
|
end
|
34
31
|
|
35
32
|
class SpectreHttpRequest < Spectre::DslClass
|
@@ -112,6 +109,10 @@ module Spectre
|
|
112
109
|
@__req['use_ssl'] = true
|
113
110
|
end
|
114
111
|
|
112
|
+
def no_log!
|
113
|
+
@__req['no_log'] = true
|
114
|
+
end
|
115
|
+
|
115
116
|
def to_s
|
116
117
|
@__req.to_s
|
117
118
|
end
|
@@ -230,6 +231,10 @@ module Spectre
|
|
230
231
|
# do nothing
|
231
232
|
end
|
232
233
|
|
234
|
+
if str.length > 1000
|
235
|
+
str = str[0...1000] + "\n[...]"
|
236
|
+
end
|
237
|
+
|
233
238
|
str
|
234
239
|
end
|
235
240
|
|
@@ -314,7 +319,14 @@ module Spectre
|
|
314
319
|
|
315
320
|
req_log = "[>] #{req_id} #{req['method']} #{uri}\n"
|
316
321
|
req_log += header_to_s(net_req)
|
317
|
-
|
322
|
+
|
323
|
+
unless req['body'].nil? or req['body'].empty?
|
324
|
+
unless req['no_log']
|
325
|
+
req_log += try_format_json(req['body'], pretty: true)
|
326
|
+
else
|
327
|
+
req_log += '[...]'
|
328
|
+
end
|
329
|
+
end
|
318
330
|
|
319
331
|
@@logger.info(req_log)
|
320
332
|
|
@@ -345,7 +357,14 @@ module Spectre
|
|
345
357
|
|
346
358
|
res_log = "[<] #{req_id} #{net_res.code} #{net_res.message} (#{end_time - start_time}s)\n"
|
347
359
|
res_log += header_to_s(net_res)
|
348
|
-
|
360
|
+
|
361
|
+
unless net_res.body.nil? or net_res.body.empty?
|
362
|
+
unless req['no_log']
|
363
|
+
res_log += try_format_json(net_res.body, pretty: true)
|
364
|
+
else
|
365
|
+
res_log += '[...]'
|
366
|
+
end
|
367
|
+
end
|
349
368
|
|
350
369
|
@@logger.info(res_log)
|
351
370
|
|
@@ -361,7 +380,7 @@ module Spectre
|
|
361
380
|
end
|
362
381
|
|
363
382
|
Spectre.register do |config|
|
364
|
-
@@logger = ::
|
383
|
+
@@logger = Spectre::Logging::ModuleLogger.new(config, 'spectre/http')
|
365
384
|
@@secure_keys = config['secure_keys'] || []
|
366
385
|
@@debug = config['debug']
|
367
386
|
|
data/lib/spectre/logger/file.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Spectre
|
2
|
-
module
|
2
|
+
module Logging
|
3
3
|
class File
|
4
4
|
def initialize config
|
5
5
|
raise 'No log format section in config for console logger' unless config.key? 'log_format' and config['log_format'].key? 'file'
|
@@ -9,77 +9,77 @@ module Spectre
|
|
9
9
|
@fmt_end_group = @config['end_group']
|
10
10
|
@fmt_sep = @config['separator']
|
11
11
|
|
12
|
-
@file_log = ::Logger.new
|
12
|
+
@file_log = ::Logger.new(config['log_file'], progname: 'spectre')
|
13
13
|
@file_log.level = config['debug'] ? 'DEBUG' : 'INFO'
|
14
14
|
end
|
15
15
|
|
16
16
|
def start_subject subject
|
17
|
-
@file_log.debug
|
17
|
+
@file_log.debug("start running subject '#{subject.desc}'")
|
18
18
|
end
|
19
19
|
|
20
20
|
def end_subject subject
|
21
|
-
@file_log.debug
|
21
|
+
@file_log.debug("subject '#{subject.desc}' finished")
|
22
22
|
end
|
23
23
|
|
24
24
|
def start_context context
|
25
25
|
if context and context.__desc
|
26
|
-
@file_log.debug
|
26
|
+
@file_log.debug("start running context '#{context.__desc}'")
|
27
27
|
else
|
28
|
-
@file_log.debug
|
28
|
+
@file_log.debug("start running main context of #{context.__subject.desc}")
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
def end_context context
|
33
33
|
if context and context.__desc
|
34
|
-
@file_log.debug
|
34
|
+
@file_log.debug("context '#{context.__desc}' finished")
|
35
35
|
else
|
36
|
-
@file_log.debug
|
36
|
+
@file_log.debug("main context finished of #{context.__subject.desc}")
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
def start_spec spec, data=nil
|
41
41
|
log_msg = "start running spec [#{spec.name}] '#{spec.desc}'"
|
42
42
|
log_msg += " with data #{data}" if data
|
43
|
-
@file_log.debug
|
43
|
+
@file_log.debug(log_msg)
|
44
44
|
end
|
45
45
|
|
46
46
|
def end_spec spec, data=nil
|
47
47
|
log_msg = "running spec [#{spec.name}] '#{spec.desc}'"
|
48
48
|
log_msg += " with data #{data}" if data
|
49
49
|
log_msg += " finished"
|
50
|
-
@file_log.debug
|
50
|
+
@file_log.debug(log_msg)
|
51
51
|
end
|
52
52
|
|
53
53
|
def log_separator desc
|
54
54
|
desc = @fmt_sep.gsub('<desc>', desc) if @fmt_sep
|
55
|
-
@file_log.info
|
55
|
+
@file_log.info(desc)
|
56
56
|
end
|
57
57
|
|
58
58
|
def start_group desc
|
59
59
|
desc = @fmt_start_group.gsub('<desc>', desc) if @fmt_start_group
|
60
|
-
@file_log.info
|
60
|
+
@file_log.info(desc)
|
61
61
|
end
|
62
62
|
|
63
63
|
def end_group desc
|
64
64
|
desc = @fmt_end_group.gsub('<desc>', desc) if @fmt_end_group
|
65
|
-
@file_log.info
|
65
|
+
@file_log.info(desc)
|
66
66
|
end
|
67
67
|
|
68
68
|
def log_process desc
|
69
|
-
@file_log.debug
|
69
|
+
@file_log.debug(desc)
|
70
70
|
end
|
71
71
|
|
72
72
|
def log_info message
|
73
|
-
@file_log.info
|
73
|
+
@file_log.info("#{Status::INFO} #{message}")
|
74
74
|
end
|
75
75
|
|
76
76
|
def log_debug message
|
77
|
-
@file_log.debug
|
77
|
+
@file_log.debug("#{Status::DEBUG} #{message}")
|
78
78
|
end
|
79
79
|
|
80
80
|
def log_error spec, exception
|
81
81
|
file, line = exception.backtrace[0].match(/(.*\.rb):(\d+)/).captures
|
82
|
-
@file_log.error
|
82
|
+
@file_log.error("An unexpected error occurred at '#{file}:#{line}' while running spec '#{spec.name}': [#{exception.class}] #{exception.message}\n#{exception.backtrace.join "\n"}")
|
83
83
|
end
|
84
84
|
|
85
85
|
def log_skipped spec, message=nil
|
@@ -89,13 +89,13 @@ module Spectre
|
|
89
89
|
txt += ': ' + message
|
90
90
|
end
|
91
91
|
|
92
|
-
@file_log.warn
|
92
|
+
@file_log.warn(txt)
|
93
93
|
end
|
94
94
|
|
95
95
|
def log_status desc, status, annotation=nil
|
96
96
|
msg = "expected #{desc}...#{status.upcase}"
|
97
97
|
msg += " - #{annotation}" if annotation
|
98
|
-
@file_log.debug
|
98
|
+
@file_log.debug(msg)
|
99
99
|
end
|
100
100
|
end
|
101
101
|
end
|