spectre-core 1.12.4 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d2cb2622682713c0fc37e7c0e679aa0d93f01ac9af389c8430496a272608038
4
- data.tar.gz: 8b313cd7952c0b9e4baf9e8f0cec0af397d1f8cf8fc25760204714f687718df8
3
+ metadata.gz: fd2c5dd03f2ded27246d351696a749bf0f0fbb06ff87ecc27363873202ecb1ac
4
+ data.tar.gz: a17d75c2581c6f64f58664b78c68449936610f8fa9c6c313dc73011da59094c6
5
5
  SHA512:
6
- metadata.gz: c3e939b9e9851ece96d27e31d19fa7f4c5b26bd9141e28e2e5964b5f20ed1f9c9b0f4a77800b87c411d1c271d0b4acf1afa1f50359e832842e241a1ba536b811
7
- data.tar.gz: d105a5a9924cba80b028790a538945087ef0e19a30763e619b712c1d7b31b54259a03504a5a52d1f1cc24be6a03f1e8185d499ed9e7343a17655c4336f22dd40
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::Logger::Console',
30
- 'Spectre::Logger::File',
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
- opt_parser = OptionParser.new do |opts|
83
- opts.banner = %{Spectre #{Spectre::VERSION}
86
+ $COMMAND = ['spectre'].concat(ARGV.clone).join(' ')
84
87
 
85
- Usage: spectre [command] [options]
88
+ OptionParser.new do |opts|
89
+ opts.banner = %{Spectre #{Spectre::VERSION}
86
90
 
87
- Commands:
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
- Specific options:}
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
- shortdate: now.strftime('%Y-%m-%d'),
306
- date: now.strftime('%Y-%m-%d_%H%M%S'),
307
- timestamp: now.strftime('%s'),
308
- subject: 'spectre',
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 cfg['log_file']
312
- FileUtils.makedirs log_dir unless Dir.exists? log_dir
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::Logger.debug! if cfg['debug']
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::Logger.add(logger)
360
+ Spectre::Logging.add(logger)
354
361
  end if cfg['loggers']
355
362
 
356
363
  specs = Spectre.specs(cfg['specs'], cfg['tags'])
@@ -8,23 +8,23 @@ module Spectre
8
8
  module Assertion
9
9
  class ::Object
10
10
  def should_be(val)
11
- raise AssertionFailure.new("The value '#{self.to_s.trim}' should be '#{val.to_s.trim}'", val, self) unless self.to_s == val.to_s
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("The value '#{self.to_s.trim}' should be empty", nil, self) unless self.nil?
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("The value '#{self.to_s.trim}' should not be '#{val.to_s.trim}'", val, self) unless self.to_s != val.to_s
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("The value '#{self.to_s.trim}' should not exist, but it does", val, self) unless self.to_s != nil
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('The value is empty', 'nothing', self) unless self != nil
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("There is nothing, but the value should be '#{val.to_s.trim}'", val, nil) unless val == nil
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('The value does not exist', 'nil')
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('The object should be empty', nil, self) unless self.empty?
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('The object should not be empty', nil, self) if self.empty?
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('The object should be empty', nil, self) unless self.to_h.empty?
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('The object should not be empty', nil, self) if self.to_h.empty?
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("The list [#{list.join(', ').trim}] should contain '#{val.to_s.trim}'", val, list) unless list.include? val
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("The list [#{list.join(', ').trim}] should not contain '#{val.to_s.trim}'", val, list) if list.include? val
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('The list is not empty', self) unless self.empty?
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('The list is empty', self) if self.empty?
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("The text '#{self.trim}' should be '#{val.to_s.trim}'", val, self) unless self == val
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("The text '#{self.trim}' should be empty", nil, self) unless self.empty?
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("The text '#{self.trim}' should not be '#{val.to_s.trim}'", val, self) unless self != val
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('The text should not be empty', 'nothing', self) unless not self.empty?
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("The value is nil") if value.nil?
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("The text '#{self.to_s.trim}' should contain #{evaluation.to_s}", evaluation, self)
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("The text '#{self.trim}' should not contain '#{val.trim}'", val, self) if self.include? val
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("The text '#{self.trim}' should match '#{val}'", regex, self) unless self.match(regex)
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("The text '#{self.trim}' should not match '#{val}'", regex, self) if self.match(regex)
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
- Logger.log_process("expect #{desc}")
234
+ Logging.log_process("expect #{desc}")
241
235
  yield
242
- Logger.log_status(desc, Logger::Status::OK)
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
- Logger.log_status(desc, Logger::Status::FAILED)
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
- Logger.log_status(desc, Logger::Status::ERROR)
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
- Logger.log_info(prefix) if desc
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 = ::Logger.new(config['log_file'], progname: 'spectre/assertion')
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
@@ -12,7 +12,7 @@ module Spectre
12
12
  end
13
13
  end
14
14
 
15
- Spectre.register do |config|
15
+ Spectre.register do |_config|
16
16
  @@bag = OpenStruct.new
17
17
  end
18
18
 
data/lib/spectre/curl.rb CHANGED
@@ -310,7 +310,7 @@ module Spectre::Curl
310
310
 
311
311
  start_time = Time.now
312
312
 
313
- stdin, stdout, stderr, wait_thr = Open3.popen3(sys_cmd)
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 |header|
363
- res_log += "#{header[0].to_s.ljust(30, '.')}: #{header[1].to_s}\n"
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 = ::Logger.new(config['log_file'], progname: 'spectre/curl')
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'
@@ -119,6 +119,10 @@ class ::Hash
119
119
  end
120
120
 
121
121
  class ::Array
122
+ def first_element
123
+ self[0]
124
+ end
125
+
122
126
  def last_element
123
127
  self[-1]
124
128
  end
@@ -42,8 +42,6 @@ module Spectre::Http
42
42
  net_req['X-Auth-Token'] = token
43
43
  end
44
44
 
45
- private
46
-
47
45
  def self.authenticate keystone_url, username, password, project, domain, cert
48
46
  auth_data = {
49
47
  auth: {
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
- req_log += try_format_json(req['body'], pretty: true) if req['body'] != nil and not req['body'].empty?
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
- res_log += try_format_json(net_res.body, pretty: true) unless net_res.body.nil? or net_res.body.empty?
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 = ::Logger.new(config['log_file'], progname: 'spectre/http')
383
+ @@logger = Spectre::Logging::ModuleLogger.new(config, 'spectre/http')
365
384
  @@secure_keys = config['secure_keys'] || []
366
385
  @@debug = config['debug']
367
386
 
@@ -1,7 +1,7 @@
1
1
  require 'ectoplasm'
2
2
 
3
3
  module Spectre
4
- module Logger
4
+ module Logging
5
5
  class Console
6
6
  def initialize config
7
7
  raise 'No log format section in config for console logger' unless config.key? 'log_format' and config['log_format'].key? 'console'
@@ -1,5 +1,5 @@
1
1
  module Spectre
2
- module Logger
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 config['log_file'], progname: 'spectre'
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 "start running subject '#{subject.desc}'"
17
+ @file_log.debug("start running subject '#{subject.desc}'")
18
18
  end
19
19
 
20
20
  def end_subject subject
21
- @file_log.debug "subject '#{subject.desc}' finished"
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 "start running context '#{context.__desc}'"
26
+ @file_log.debug("start running context '#{context.__desc}'")
27
27
  else
28
- @file_log.debug "start running main context of #{context.__subject.desc}"
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 "context '#{context.__desc}' finished"
34
+ @file_log.debug("context '#{context.__desc}' finished")
35
35
  else
36
- @file_log.debug "main context finished of #{context.__subject.desc}"
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 log_msg
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 log_msg
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 desc
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 desc
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 desc
65
+ @file_log.info(desc)
66
66
  end
67
67
 
68
68
  def log_process desc
69
- @file_log.debug desc
69
+ @file_log.debug(desc)
70
70
  end
71
71
 
72
72
  def log_info message
73
- @file_log.info "#{Status::INFO} #{message}"
73
+ @file_log.info("#{Status::INFO} #{message}")
74
74
  end
75
75
 
76
76
  def log_debug message
77
- @file_log.debug "#{Status::DEBUG} #{message}"
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 "An unexpected error occurred at '#{file}:#{line}' while running spec '#{spec.name}': [#{exception.class}] #{exception.message}\n#{exception.backtrace.join "\n"}"
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 txt
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 msg
98
+ @file_log.debug(msg)
99
99
  end
100
100
  end
101
101
  end