<commit_before>require 'pathname'
require 'json'
require 'tempfile'

$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'cmds'

ECHO_CMD = "./test/echo_cmd.rb"

def echo_cmd_data result
  expect( result.cmd ).to start_with ECHO_CMD
  expect( result ).to be_instance_of Cmds::Result
  expect( result.ok? ).to be true
  data = JSON.load result.out
  expect( data ).to be_instance_of Hash
  data
end

def echo_cmd_key result, key
  data = echo_cmd_data result
  expect( data.key? key ).to be true
  data[key]
end

def echo_cmd_argv result
  echo_cmd_key result, 'ARGV'
end

def echo_cmd_stdin result
  echo_cmd_key result, 'stdin'<commit_msg>Require `nrser/rspex` in spec_helper<commit_after>require 'pathname'
require 'json'
require 'tempfile'

$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'cmds'

require 'nrser/rspex'

ECHO_CMD = "./test/echo_cmd.rb"

def echo_cmd_data result
  expect( result.cmd ).to start_with ECHO_CMD
  expect( result ).to be_instance_of Cmds::Result
  expect( result.ok? ).to be true
  data = JSON.load result.out
  expect( data ).to be_instance_of Hash
  data
end

def echo_cmd_key result, key
  data = echo_cmd_data result
  expect( data.key? key ).to be true
  data[key]
end

def echo_cmd_argv result
  echo_cmd_key result, 'ARGV'
end

def echo_cmd_stdin result
  echo_cmd_key result, 'stdin'
{'fraction_non_alphanumeric': 0.10324483775811209, 'fraction_numerical': 0.0, 'mean_word_length': 4.4063745019920315, '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': '5481770', 'n_tokens_mistral': 504, 'n_tokens_neox': 497, 'n_words': 142}