Class: Helmsnap::Check

Inherits:
Service show all
Defined in:
lib/helmsnap/check.rb

Instance Method Summary collapse

Methods inherited from Service

call

Constructor Details

#initialize(config) ⇒ Check

Returns a new instance of Check.



4
5
6
7
# File 'lib/helmsnap/check.rb', line 4

def initialize(config)
  super()
  self.config = config
end

Instance Method Details

#callObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/helmsnap/check.rb', line 9

def call
  temp_dir_path = Pathname.new(Dir.mktmpdir)

  Helmsnap::Generate.call(config, snapshots_path: temp_dir_path)

  result = run_cmd("which", "colordiff", allow_failure: true)
  util = result.success ? "colordiff" : "diff"

  cmd_parts = [util, "--unified", "--recursive", config.snapshots_path, temp_dir_path]
  diff = run_cmd(*cmd_parts, allow_failure: true).output

  diff.strip.empty?
ensure
  FileUtils.rmtree(temp_dir_path)
end