class TestBase

Constants

TEMPNAME

Attributes

tmux[R]

Public Instance Methods

fzf(*opts) click to toggle source
# File lib/helpers/fzf/test/test_go.rb, line 195
def fzf(*opts)
  fzf!(*opts) + " > #{tempname}.tmp; mv #{tempname}.tmp #{tempname}"
end
fzf!(*opts) click to toggle source
# File lib/helpers/fzf/test/test_go.rb, line 199
def fzf!(*opts)
  opts = opts.map do |o|
    case o
    when Symbol
      o = o.to_s
      o.length > 1 ? "--#{o.tr('_', '-')}" : "-#{o}"
    when String, Numeric
      o.to_s
    end
  end.compact
  "#{FZF} #{opts.join(' ')}"
end
readonce() click to toggle source
# File lib/helpers/fzf/test/test_go.rb, line 186
def readonce
  wait { assert_path_exists tempname }
  File.read(tempname)
ensure
  File.unlink(tempname) while File.exist?(tempname)
  @temp_suffix += 1
  tmux.prepare
end
tempname() click to toggle source
# File lib/helpers/fzf/test/test_go.rb, line 174
def tempname
  @temp_suffix ||= 0
  [TEMPNAME,
   caller_locations.map(&:label).find { |l| l.start_with?('test_') },
   @temp_suffix].join('-')
end
writelines(path, lines) click to toggle source
# File lib/helpers/fzf/test/test_go.rb, line 181
def writelines(path, lines)
  File.unlink(path) while File.exist?(path)
  File.open(path, 'w') { |f| f.puts lines }
end