Module: Foundries::Recording

Defined in:
lib/foundries/recording.rb,
lib/foundries/recording/node.rb,
lib/foundries/recording/reporter.rb,
lib/foundries/recording/collector.rb,
lib/foundries/recording/rake_task.rb,
lib/foundries/recording/aggregator.rb

Defined Under Namespace

Classes: Aggregator, Collector, Node, RakeTask, Reporter

Constant Summary collapse

DEFAULT_OUTPUT_PATH =
"tmp/foundries/recording.json"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.enabled=(value) ⇒ Object (writeonly)

Sets the attribute enabled

Parameters:

  • value

    the value to set the attribute enabled to.



11
12
13
# File 'lib/foundries/recording.rb', line 11

def enabled=(value)
  @enabled = value
end

.output_pathObject



22
23
24
# File 'lib/foundries/recording.rb', line 22

def output_path
  @output_path || DEFAULT_OUTPUT_PATH
end

Class Method Details

.collectorObject



18
19
20
# File 'lib/foundries/recording.rb', line 18

def collector
  @collector ||= Collector.new
end

.enabled?Boolean

Returns:

  • (Boolean)


13
14
15
16
# File 'lib/foundries/recording.rb', line 13

def enabled?
  return @enabled unless @enabled.nil?
  ENV["FOUNDRIES_RECORD"] == "1"
end

.report!Object



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/foundries/recording.rb', line 42

def report!
  total_tests = collector.results.size
  reporter = Reporter.new(
    results: collector.results,
    total_creates: collector.total_creates,
    total_tests: total_tests
  )
  path = worker_output_path
  reporter.write_json(path)
  $stdout.puts reporter.summary(json_path: path)
end

.reset!Object



36
37
38
39
40
# File 'lib/foundries/recording.rb', line 36

def reset!
  @collector = nil
  @enabled = nil
  @output_path = nil
end

.worker_output_pathObject



26
27
28
29
30
31
32
33
34
# File 'lib/foundries/recording.rb', line 26

def worker_output_path
  worker_id = ENV["TEST_ENV_NUMBER"]
  return output_path if worker_id.nil?

  suffix = worker_id.empty? ? Process.pid.to_s : worker_id
  base = output_path
  ext = File.extname(base)
  "#{base.chomp(ext)}-#{suffix}#{ext}"
end