Class: Rdm::CLI::DiffSpecRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/rdm/cli/diff_spec_runner.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(revision, path, stdout, show_output) ⇒ DiffSpecRunner

Returns a new instance of DiffSpecRunner.



6
7
8
9
10
11
# File 'lib/rdm/cli/diff_spec_runner.rb', line 6

def initialize(revision, path, stdout, show_output)
  @revision    = revision
  @path        = path
  @stdout      = stdout
  @show_output = show_output
end

Class Method Details

.run(revision: 'HEAD', path:, stdout: STDOUT, show_output: true) ⇒ Object



2
3
4
# File 'lib/rdm/cli/diff_spec_runner.rb', line 2

def self.run(revision: 'HEAD', path:, stdout: STDOUT, show_output: true)
  Rdm::CLI::DiffSpecRunner.new(revision, path, stdout, show_output).run
end

Instance Method Details

#runObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/rdm/cli/diff_spec_runner.rb', line 13

def run
  changed_packages = Rdm::Handlers::DiffPackageHandler.handle(
    path:     @path, 
    revision: @revision
  )
  
  if changed_packages.empty?
    @stdout.puts "No modified packages were found. Type `git add .` to index all changes..."
    
    return nil
  end

  @stdout.puts "Tests for the following packages will run:\n  - #{changed_packages.join("\n  - ")}\n\n"

  changed_packages.each do |package| 
    Rdm::SpecRunner.run(
      package:               package,
      path:                  @path,
      show_missing_packages: false,
      stdout:                @stdout,
      show_output:           @show_output
    )
  end

rescue Rdm::Errors::GitRepositoryNotInitialized
  @stdout.puts "Git repository is not initialized. Use `git init .`"
  
  return nil
end