<commit_before>require 'spec_helper'

describe 'expect_json_keys' do
  it 'should fail when json keys are missing' do
    mock_get('simple_json')
    get '/simple_json', {}
    expect{expect_json_keys([:foo, :bar, :baz, :bax])}.to raise_error
  end

  it 'should ensure correct json keys' do
    mock_get('simple_json')
    get '/simple_json', {}
    expect_json_keys([:foo, :bar, :baz])
  end 

  it 'should ensure correct partial json keys' do
    mock_get('simple_json')
    get '/simple_json', {}
    expect_json_keys([:foo, :bar])
  end 
end<commit_msg>Added tests for expect_json_keys with path<commit_after>require 'spec_helper'

describe 'expect_json_keys' do
  it 'should fail when json keys are missing' do
    mock_get('simple_json')
    get '/simple_json', {}
    expect{expect_json_keys([:foo, :bar, :baz, :bax])}.to raise_error
  end

  it 'should ensure correct json keys' do
    mock_get('simple_json')
    get '/simple_json', {}
    expect_json_keys([:foo, :bar, :baz])
  end 

  it 'should ensure correct partial json keys' do
    mock_get('simple_json')
    get '/simple_json', {}
    expect_json_keys([:foo, :bar])
  end

  it 'should ensure json keys with path' do
    mock_get('simple_nested_path')
    get '/simple_nested_path', {}
    expect_json_keys('address', [:street, :city])
  end 

  it 'should fail when keys are missing with path' do
    mock_get('simple_nested_path')
    get '/simple_nested_path', {}
    expect{expect_json_keys('address', [:bad])}.to raise_error
  end      
end
{'fraction_non_alphanumeric': 0.1261558784676354, 'fraction_numerical': 0.0, 'mean_word_length': 3.9672131147540983, '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': '807756', 'n_tokens_mistral': 520, 'n_tokens_neox': 506, 'n_words': 140}