<commit_before>$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'rspec'
require 'marvel_api'

# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}

RSpec.configure do |config|
  
end

Marvel.configure do |config|
  
end<commit_msg>Adds mock & stub machinery for testing<commit_after>$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))

require 'rspec'
require 'webmock/rspec'
require 'marvel_api'

# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }

RSpec.configure do |config|
  config.expect_with(:rspec) { |c| c.syntax = :expect }
end

WebMock.disable_net_connect!(allow_localhost: true)

def marvel_test_client
  Marvel::Client.new.tap do |client|
    client.configure do |config|
      config.api_key = '1234'
      config.private_key = 'abcd'
    end
  end
end

AUTH = '?ts=1&apikey=1234&hash=ffd275c5130566a2916217b101f26150'

def stub_get(path, options = {})
  file = options.fetch(:returns)
  stub_request(:get, Marvel::Connection::BASE_API_URL + path + AUTH).
    to_return(body: fixture(file))
end

def fixture_path
  File.expand_path('../fixtures', __FILE__)
end

def fixture(file)
  File.new(fixture_path + '/' + file)
end

module Marvel
  module Request
    private
    def auth
      {
        ts: '1',
        apikey: api_key,
        hash: hash('1')
      }
    end
  end
end
{'fraction_non_alphanumeric': 0.1426003594967046, 'fraction_numerical': 0.02156980227681246, 'mean_word_length': 4.26813880126183, 'pattern_counts': {'":': 0, '<': 3, '<?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': '468363', 'n_tokens_mistral': 610, 'n_tokens_neox': 588, 'n_words': 129}