Class: Guard::JestRunner::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/guard/jest_runner/runner.rb

Overview

This class runs jest command, retrieves result and notifies. An instance of this class is intended to invoke jest only once in its lifetime.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Runner

Returns a new instance of Runner.



11
12
13
# File 'lib/guard/jest_runner/runner.rb', line 11

def initialize(options)
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



15
16
17
# File 'lib/guard/jest_runner/runner.rb', line 15

def options
  @options
end

Instance Method Details

#failed_pathsObject



31
32
33
# File 'lib/guard/jest_runner/runner.rb', line 31

def failed_paths
  result[:testResults].select { |f| f[:status] == "failed" }.map { |f| f[:name] }.uniq
end

#run(paths) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/guard/jest_runner/runner.rb', line 17

def run(paths)
  paths = options[:default_paths] unless paths

  passed = run_for_check(paths)
  case options[:notification]
  when :failed
    notify(passed) unless passed
  when true
    notify(passed)
  end

  passed
end