Module: RSpeed::Observer

Defined in:
lib/rspeed/observer.rb

Class Method Summary collapse

Class Method Details

.after(example) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/rspeed/observer.rb', line 7

def after(example)
  file_path   = example.[:file_path]
  line_number = example.[:line_number]
  spent_time  = example.clock.now - example.[:start_at]

  json = { file: "#{file_path}:#{line_number}", time: spent_time }.to_json

  RSpeed::Redis.client.rpush(RSpeed::Variable.profile, json)
end

.after_suiteObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rspeed/observer.rb', line 17

def after_suite
  RSpeed::Redis.set(RSpeed::Variable.pipe, true)

  return unless RSpeed::Redis.specs_finished?

  RSpeed::Redis.version_the_result if RSpeed::Redis.result?
  RSpeed::Splitter.consolidate
  RSpeed::Reporter.call
  RSpeed::Redis.clean

  RSpeed::Logger.log(self, __method__, 'RSpeed finished.')
end

.before(example) ⇒ Object



30
31
32
# File 'lib/rspeed/observer.rb', line 30

def before(example)
  example.(start_at: example.clock.now)
end

.before_suiteObject



34
35
36
37
38
39
# File 'lib/rspeed/observer.rb', line 34

def before_suite
  RSpeed::Logger.log(self, __method__, 'Cleanning current flag and profile.')

  RSpeed::Redis.destroy(pattern: RSpeed::Variable.pipe)
  RSpeed::Redis.destroy(pattern: RSpeed::Variable.profile)
end