<commit_before>require 'test_helper'

class RoundTest < ActiveSupport::TestCase
  test "newly created round has randomly generated url string" do
    r = Round.new
    assert_not_nil r.url
    assert_match /^[[:xdigit:]]{6}$/, r.url

    r2 = Round.new
    assert_not_equal r.url, r2.url
  end

  test "newly created round has expire time of one hour" do
    r = Round.new
    assert_not_nil r.expire_time
    assert Time.now + 1.hours - r.expire_time < 1 # fuzzy time comparison
  end

  test "url and expire_time persist on save" do
    r = Round.new
    url = r.url
    r.save

    r2 = Round.where(url: url).first

    assert_equal r2.url, r.url
    assert_equal r2.expire_time, r.expire_time
  end
end<commit_msg>Test Round.seconds_left returns time until round expires<commit_after>require 'test_helper'

class RoundTest < ActiveSupport::TestCase
  test "newly created round has randomly generated url string" do
    r = Round.new
    assert_not_nil r.url
    assert_match /^[[:xdigit:]]{6}$/, r.url

    r2 = Round.new
    assert_not_equal r.url, r2.url
  end

  test "newly created round has expire time of one hour" do
    r = Round.new
    assert_not_nil r.expire_time
    assert Time.now + 1.hours - r.expire_time < 1 # fuzzy time comparison
  end

  test "url and expire_time persist on save" do
    r = Round.new
    url = r.url
    r.save

    r2 = Round.where(url: url).first

    assert_equal r2.url, r.url
    assert_equal r2.expire_time, r.expire_time
  end

  test "seconds_left returns time until round expires" do
    r = Round.new

    now = Time.now
    r.expire_time = now + 1.hours

    assert r.seconds_left - 1.hours < 1
  end
end
{'fraction_non_alphanumeric': 0.08509354254677128, 'fraction_numerical': 0.011466505733252867, 'mean_word_length': 2.855813953488372, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4591125', 'n_tokens_mistral': 604, 'n_tokens_neox': 563, 'n_words': 177}