class Assert::View

Attributes

config[R]

Public Class Methods

new(config, output_io) click to toggle source
# File lib/assert/view.rb, line 52
def initialize(config, output_io)
  @config, @output_io, = config, output_io
  @output_io.sync = true if @output_io.respond_to?(:sync=)
end
require_user_view(view_name) click to toggle source

this method is used to bring in custom user-specific views require views by passing either a full path to the view ruby file or passing the name of a view installed in ~/.assert/views

# File lib/assert/view.rb, line 17
def self.require_user_view(view_name)
  views_file = File.expand_path(
    File.join("#{ENV["HOME"]}/.assert/views", view_name, "lib", view_name),
  )

  if File.exist?(view_name) || File.exist?(view_name + ".rb")
    require view_name
  elsif File.exist?(views_file + ".rb")
    require views_file
  else
    msg = +"[WARN] Can't find or require #{view_name.inspect} view."
    unless view_name.match(%r{\A/})
      msg << " Did you install it in `~/.assert/views`?"
    end
    warn msg
  end
end

Public Instance Methods

after_load() click to toggle source
# File lib/assert/view.rb, line 89
def after_load
end
after_test(test) click to toggle source
# File lib/assert/view.rb, line 101
def after_test(test)
end
before_load(test_files) click to toggle source

available callbacks from the runner:

  • ‘before_load`: called at the beginning, before the suite is loaded

  • ‘after_load`: called after the suite is loaded, just before `on_start`

    functionally equivalent to `on_start`
    
  • ‘on_start`: called when a loaded test suite starts running

  • ‘before_test`: called before a test starts running

    the test is passed as an arg
    
  • ‘on_result`: called when a running tests generates a result

    the result is passed as an arg
    
  • ‘after_test`: called after a test finishes running

    the test is passed as an arg
    
  • ‘on_finish`: called when the test suite is finished running

  • ‘on_info`: called when the INFO signal is triggered whil runninng

    the test suite
    
  • ‘on_interrupt`: called when the test suite is interrupted while running

    the interrupt exception is passed as an arg
    
# File lib/assert/view.rb, line 86
def before_load(test_files)
end
before_test(test) click to toggle source
# File lib/assert/view.rb, line 95
def before_test(test)
end
is_tty?() click to toggle source
# File lib/assert/view.rb, line 61
def is_tty?
  !!@output_io.isatty
end
on_finish() click to toggle source
# File lib/assert/view.rb, line 104
def on_finish
end
on_info(test) click to toggle source
# File lib/assert/view.rb, line 107
def on_info(test)
end
on_interrupt(err) click to toggle source
# File lib/assert/view.rb, line 110
def on_interrupt(err)
end
on_result(result) click to toggle source
# File lib/assert/view.rb, line 98
def on_result(result)
end
on_start() click to toggle source
# File lib/assert/view.rb, line 92
def on_start
end
print(*args) click to toggle source
puts(*args) click to toggle source

IO capture

# File lib/assert/view.rb, line 115
def puts(*args)
  @output_io.puts(*args)
end
view() click to toggle source
# File lib/assert/view.rb, line 57
def view
  self
end