Sha256: 408250ffc79df62618c6a0c04c7bcd948f100e649e94b7866d1a064ba13f0e9a

Contents?: true

Size: 1.04 KB

Versions: 24

Compression:

Stored size: 1.04 KB

Contents

helpers do
  
  ##
  # Return dotted assertion graph for _assertions_.
  
  def assertion_graph_for assertions
    return if assertions.empty?
    assertions.map do |assertion|
      assertion['passed'] ? green('.') : red('.')
    end.join
  end
  
  ##
  # Override Sinatra's #send_file to prevent caching.
  
  def send_file *args
    response['Cache-Control'] = 'no-cache'
    super
  end
  
  ##
  # Find the browser name for the current user agent.
  
  def browser_name
    Browser.subclasses.find do |browser|
      browser.matches_agent? env['HTTP_USER_AGENT']
    end.new
  rescue
    'Unknown'
  end
  
  ##
  # Wrap _string_ with ansi escape sequence using _code_.
  
  def color string, code
    "\e[#{code}m#{string}\e[0m"
  end
  
  ##
  # Bold _string_.
  
  def bold string
    color string, 1
  end
  
  ##
  # Color _string_ red.
  
  def red string  
    color string, 31
  end
  
  ##
  # Color _string_ green.
  
  def green string
    color string, 32
  end
  
  ##
  # Color _string_ blue.
  
  def blue string
    color string, 34
  end
end

Version data entries

24 entries across 24 versions & 4 rubygems

Version Path
gentooboontoo-jspec-4.3.3 src/helpers.rb
bootcamp-0.1.4 vendor/test_suites/jspec/src/helpers.rb
bootcamp-0.1.0 vendor/test_suites/jspec/src/helpers.rb
jspec-4.3.3 src/helpers.rb
jspec-4.3.2 src/helpers.rb
jspec-steventux-3.3.2.1 src/helpers.rb
jspec-steventux-3.3.2 src/helpers.rb
jspec-4.3.1 src/helpers.rb
jspec-4.3.0 src/helpers.rb
jspec-4.2.1 src/helpers.rb
jspec-4.2.0 src/helpers.rb
jspec-4.1.0 src/helpers.rb
jspec-4.0.0 src/helpers.rb
jspec-3.3.3 src/helpers.rb
jspec-3.3.2 src/helpers.rb
jspec-3.3.1 src/helpers.rb
jspec-3.3.0 src/helpers.rb
jspec-3.2.1 src/helpers.rb
jspec-3.2.0 src/helpers.rb
jspec-3.1.3 src/helpers.rb