<commit_before>exit 0 if ENV["TRAVIS_PULL_REQUEST"] && ENV["TRAVIS_PULL_REQUEST"] != "false"

require "bundler/setup"
require "tinify"

require "minitest/autorun"

describe "client" do
  abort "Set the TINIFY_KEY environment variable." unless ENV["TINIFY_KEY"]
  Tinify.key = ENV["TINIFY_KEY"]

  unoptimized_path = File.expand_path("../examples/voormedia.png", __FILE__)
  optimized = Tinify.from_file(unoptimized_path)

  it "should compress" do
    Tempfile.open("optimized.png") do |tmp|
      optimized.to_file(tmp.path)
      assert_operator tmp.size, :<, 1500
    end
  end

  it "should resize" do
    Tempfile.open("resized.png") do |tmp|
      optimized.resize(method: "fit", width: 50, height: 20).to_file(tmp.path)
      assert_operator tmp.size, :<, 800
    end
  end
end<commit_msg>Rename var for consistency.<commit_after>exit 0 if ENV["TRAVIS_PULL_REQUEST"] && ENV["TRAVIS_PULL_REQUEST"] != "false"

require "bundler/setup"
require "tinify"

require "minitest/autorun"

describe "client" do
  abort "Set the TINIFY_KEY environment variable." unless ENV["TINIFY_KEY"]
  Tinify.key = ENV["TINIFY_KEY"]

  unoptimized_path = File.expand_path("../examples/voormedia.png", __FILE__)
  optimized = Tinify.from_file(unoptimized_path)

  it "should compress" do
    Tempfile.open("optimized.png") do |file|
      optimized.to_file(file.path)
      assert_operator file.size, :<, 1500
    end
  end

  it "should resize" do
    Tempfile.open("resized.png") do |file|
      optimized.resize(method: "fit", width: 50, height: 20).to_file(file.path)
      assert_operator file.size, :<, 800
    end
  end
end
{'fraction_non_alphanumeric': 0.12965260545905707, 'fraction_numerical': 0.01488833746898263, 'mean_word_length': 4.2200647249190935, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1506480', 'n_tokens_mistral': 619, 'n_tokens_neox': 582, 'n_words': 126}