<commit_before>require "minitest_helper"
require "chandler/cli"

class Chandler::CLITest < Minitest::Test
  include LoggerMocks

  def setup
    @args = []
    @config = Chandler::Configuration.new
    @config.logger = new_logger
    @parser = stub(:args => @args, :config => @config, :usage => "usage")
    @cli = Chandler::CLI.new(:parser => @parser)
  end

  def test_missing_command_causes_exit
    error = assert_raises(SystemExit) { @cli.run }
    assert_equal(1, error.status)
    assert_match("Please specify a command", stderr)
    assert_match("usage", stdout)
  end

  def test_unrecognized_command_causes_exit
    @args << "blergh"
    error = assert_raises(SystemExit) { @cli.run }
    assert_equal(1, error.status)
    assert_match("Unrecognized command: blergh", stderr)
    assert_match("usage", stdout)
  end

  def test_push_is_invoked_for_all_git_tags_by_default
    @args << "push"
    @config.git.stubs(:version_tags => %w[v1.0.0 v1.0.1])<commit_msg>Fix delegate warnings when using stubs on Ruby 2.5<commit_after>require "minitest_helper"
require "chandler/cli"

class Chandler::CLITest < Minitest::Test
  include LoggerMocks

  ParserStub = Struct.new(:args, :config, :usage)

  def setup
    @args = []
    @config = Chandler::Configuration.new
    @config.logger = new_logger
    @parser = ParserStub.new(@args, @config, "usage")
    @cli = Chandler::CLI.new(:parser => @parser)
  end

  def test_missing_command_causes_exit
    error = assert_raises(SystemExit) { @cli.run }
    assert_equal(1, error.status)
    assert_match("Please specify a command", stderr)
    assert_match("usage", stdout)
  end

  def test_unrecognized_command_causes_exit
    @args << "blergh"
    error = assert_raises(SystemExit) { @cli.run }
    assert_equal(1, error.status)
    assert_match("Unrecognized command: blergh", stderr)
    assert_match("usage", stdout)
  end

  def test_push_is_invoked_for_all_git_tags_by_default
    @args << "push"
    @config.git.stubs(:version_tags => %w[v1.0.0 v1.0.1])
{'fraction_non_alphanumeric': 0.12338308457711443, 'fraction_numerical': 0.008955223880597015, 'mean_word_length': 4.292105263157895, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 10, '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': '1430177', 'n_tokens_mistral': 715, 'n_tokens_neox': 697, 'n_words': 138}