<commit_before>#!/bin/bash ../test_wrapper.sh

require_relative 'AppHelpersTestBase'

class TipTests < AppHelpersTestBase

  include TipHelper

  def setup
    super
    set_one_self_class 'OneSelfDummy'
  end
  
  #- - - - - - - - - - - - - - - - - -
  
  test 'FAE414',
  'traffic light count tip' do
    params = {
      'avatar' => 'lion',
      'current_colour' => 'red',
      'red_count' => 14,
      'amber_count' => 3,
      'green_count' => 5,
      'timed_out_count' => 1,
      'bulb_count' => 23
    }
    expected =
      'lion has 23 traffic-lights<br/>' +
      "<div>&bull; 14 <span class='red'>reds</span></div>" +
      "<div>&bull; 3 <span class='amber'>ambers</span></div>" +
      "<div>&bull; 5 <span class='green'>greens</span></div>" +
      "<div>&bull; 1 <span class='timed_out'>timeout</span></div>"
    actual = traffic_light_count_tip_html(params)
    assert_equal expected, actual
  end

  #- - - - - - - - - - - - - - - - - -

  test 'BDAD52',
  'traffic light tip' do
    set_runner_class('RunnerStub')
    set_git_class('GitSpy')
    kata = make_kata
    lion = kata.start_avatar(['lion'])
    
    was_tag = 1
    was_tag_colour = 'red'
    now_tag = 2
    now_tag_colour = 'green'
    lion.dir.write('increments.json',
      [
        { "colour" => was_tag_colour,
          "number" => was_tag,
          "time" => [2015,2,5,9,28,21]
        },
        { "colour" => now_tag_colour,
          "number" => now_tag,
          "time" => [2015,2,5,9,29,15]
        }
      ]
    )

    options =
      "--ignore-space-at-eol " +
      "--find-copies-harder " +
      "#{was_tag} #{now_tag} " +
      "sandbox"

    stub =
    [
      "diff --git a/sandbox/hiker.rb b/sandbox/hiker.rb",
      "index 16c4af7..266c27e 100644",<commit_msg>ensure test/app_helpers don't create katas under /var/www/cyber-dojo/katas<commit_after>#!/bin/bash ../test_wrapper.sh

require_relative 'AppHelpersTestBase'

class TipTests < AppHelpersTestBase

  include TipHelper

  def setup
    super
    set_one_self_class 'OneSelfDummy'
  end
  
  #- - - - - - - - - - - - - - - - - -
  
  test 'FAE414',
  'traffic light count tip' do
    params = {
      'avatar' => 'lion',
      'current_colour' => 'red',
      'red_count' => 14,
      'amber_count' => 3,
      'green_count' => 5,
      'timed_out_count' => 1,
      'bulb_count' => 23
    }
    expected =
      'lion has 23 traffic-lights<br/>' +
      "<div>&bull; 14 <span class='red'>reds</span></div>" +
      "<div>&bull; 3 <span class='amber'>ambers</span></div>" +
      "<div>&bull; 5 <span class='green'>greens</span></div>" +
      "<div>&bull; 1 <span class='timed_out'>timeout</span></div>"
    actual = traffic_light_count_tip_html(params)
    assert_equal expected, actual
  end

  #- - - - - - - - - - - - - - - - - -

  test 'BDAD52',
  'traffic light tip' do
    set_runner_class 'RunnerStub'
    set_git_class    'GitSpy'
    set_disk_class   'DiskStub'
    kata = make_kata
    lion = kata.start_avatar(['lion'])
    
    was_tag = 1
    was_tag_colour = 'red'
    now_tag = 2
    now_tag_colour = 'green'
    lion.dir.write('increments.json',
      [
        { "colour" => was_tag_colour,
          "number" => was_tag,
          "time" => [2015,2,5,9,28,21]
        },
        { "colour" => now_tag_colour,
          "number" => now_tag,
          "time" => [2015,2,5,9,29,15]
        }
      ]
    )

    options =
      "--ignore-space-at-eol " +
      "--find-copies-harder " +
      "#{was_tag} #{now_tag} " +
      "sandbox"

    stub =
    [
      "diff --git a/sandbox/hiker.rb b/sandbox/hiker.rb",
      "index 16c4af7..266c27e 100644",
{'fraction_non_alphanumeric': 0.17483480176211455, 'fraction_numerical': 0.031938325991189426, 'mean_word_length': 2.078813559322034, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5082225', 'n_tokens_mistral': 1495, 'n_tokens_neox': 1379, 'n_words': 231}