<commit_before>require 'spec_helper'

def compare_hashes(h1, h2)
  h1.each do |key, val|
    if val.is_a? Hash
      compare_hashes val, h2[key]
    elsif val.is_a? Array
      val.each_with_index do |v, i|
        compare_hashes val[i], h2[key][i]
      end
    else
      val.should eq(h2[key])
    end
  end
end

describe UsersController do

  describe "resource description" do
    subject { a = Apipie.get_resource_description(UsersController) }

    it "should contain all resource methods" do
      methods = subject._methods
      methods.count.should == 5
      methods.should include("users#show")
      methods.should include("users#create")
      methods.should include("users#index")<commit_msg>Fix compare_hashes to compare nested string values<commit_after>require 'spec_helper'

def compare_hashes(h1, h2)
  if h1.is_a? String
    h1.should eq(h2)
  else
    h1.each do |key, val|
      if val.is_a? Hash
        compare_hashes val, h2[key]
      elsif val.is_a? Array
        val.each_with_index do |v, i|
          compare_hashes val[i], h2[key][i]
        end
      else
        val.should eq(h2[key])
      end
    end
  end
end

describe UsersController do

  describe "resource description" do
    subject { a = Apipie.get_resource_description(UsersController) }

    it "should contain all resource methods" do
      methods = subject._methods
      methods.count.should == 5
      methods.should include("users#show")
      methods.should include("users#create")
      methods.should include("users#index")
{'fraction_non_alphanumeric': 0.0934640522875817, 'fraction_numerical': 0.011111111111111112, 'mean_word_length': 2.9256410256410255, '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': '7475005', 'n_tokens_mistral': 498, 'n_tokens_neox': 489, 'n_words': 130}