Class: CreateGithubRelease::Assertions::GitCommandExists

Inherits:
CreateGithubRelease::AssertionBase show all
Defined in:
lib/create_github_release/assertions/git_command_exists.rb

Overview

Assert that the 'git' command is in the path

Instance Attribute Summary

Attributes inherited from CreateGithubRelease::AssertionBase

#project

Instance Method Summary collapse

Methods inherited from CreateGithubRelease::AssertionBase

#backtick_debug?, #error, #initialize, #print, #puts

Methods included from BacktickDebug

#`

Constructor Details

This class inherits a constructor from CreateGithubRelease::AssertionBase

Instance Method Details

#assert

This method returns an undefined value.

Make sure that the 'git' command is in the path

Examples:

require 'create_github_release'

options = CreateGithubRelease::CommandLine::Options.new { |o| o.release_type = 'major' }
project = CreateGithubRelease::Project.new(options)
assertion = CreateGithubRelease::Assertions::GitCommandExists.new(project)
begin
  assertion.assert
  puts 'Assertion passed'
rescue SystemExit
  puts 'Assertion failed'
end

Raises:

  • (SystemExit)

    if the assertion fails



32
33
34
35
36
37
38
39
40
# File 'lib/create_github_release/assertions/git_command_exists.rb', line 32

def assert
  print 'Checking that the git command exists...'
  `which git > /dev/null 2>&1`
  if $CHILD_STATUS.success?
    puts 'OK'
  else
    error 'The git command was not found'
  end
end