<commit_before>require_relative '../test_helper'
require_relative '../x_helper'
require_relative '../../x/exercise'

module X
  class ExerciseTest < Minitest::Test
    def test_exists_gets_passed_a_track_id
      <<-NEED_HELP
        I would like to test the exists? method by checking that request is
        called when the method is called. I however am not sure how to mock out
        method from a module and expect that it was called. Any insight into
        how to do that?
      NEED_HELP
    end
  end
end<commit_msg>adding tests for new exists method<commit_after>require_relative '../test_helper'
require_relative '../x_helper'
require_relative '../../x/exercise'

module X
  class ExerciseTest < Minitest::Test
    def test_exists_returns_true
      response = Minitest::Mock.new
      response.expect(:status, 200, [])

      X::Xapi.stub(:request, response) do
        result = X::Exercise.exists?('valid_track_id')
        assert_equal(true, result)
      end
    end

    def test_exists_returns_false
      response = Minitest::Mock.new
      response.expect(:status, 404, [])

      X::Xapi.stub(:request, response) do
        result = X::Exercise.exists?('invalid_track_id')
        assert_equal(false, result)
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09451945988880063, 'fraction_numerical': 0.004765687053216839, 'mean_word_length': 2.9873417721518987, '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': '6577723', 'n_tokens_mistral': 382, 'n_tokens_neox': 371, 'n_words': 110}