Module: Easytest::Utils

Defined in:
lib/easytest/utils.rb

Class Method Summary collapse

Class Method Details

.indent_text(text, indent_string) ⇒ Object



24
25
26
# File 'lib/easytest/utils.rb', line 24

def indent_text(text, indent_string)
  text.gsub(/^(.+)/, "#{indent_string}\\1")
end

.pluralize(singular, count) ⇒ Object



20
21
22
# File 'lib/easytest/utils.rb', line 20

def pluralize(singular, count)
  count == 1 ? singular : "#{singular}s"
end

.raise_if_no_test_name(name, method:) ⇒ Object



14
15
16
17
18
# File 'lib/easytest/utils.rb', line 14

def raise_if_no_test_name(name, method:)
  if name.nil? || name.empty?
    raise FatalError.new("`#{method}` requires a name")
  end
end


5
6
7
8
9
10
11
12
# File 'lib/easytest/utils.rb', line 5

def terminal_hyperlink(absolute_path)
  path = Pathname(absolute_path)
  dir = path.relative_path_from(Dir.pwd).dirname.to_s + File::SEPARATOR
  base = path.basename

  # https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
  "\e]8;;file://#{path}\e\\#{Rainbow(dir).dimgray}#{base}\e]8;;\e\\"
end