<commit_before>require 'test_helper'
require 'rails/generators/test_case'
require 'generators/guachiman/install/install_generator'

class InstallGeneratorTest < Rails::Generators::TestCase
  DESTINATION = File.expand_path File.join(File.dirname(__FILE__), '..', '..', 'tmp')
  FileUtils.mkdir_p DESTINATION unless Dir.exists? DESTINATION

  destination DESTINATION

  tests Guachiman::Generators::InstallGenerator
  setup :prepare_destination

  def prepare_destination
    FileUtils.rm_r    "#{DESTINATION}/app" if Dir.exists? "#{DESTINATION}/app"
    FileUtils.mkdir_p "#{DESTINATION}/app"
    FileUtils.mkdir_p "#{DESTINATION}/app/models"
  end

  test 'create permission' do
    run_generator

    assert_file 'app/models/permission.rb' do |f|
      assert_match(/class Permission/, f)
      assert_match(/include Guachiman::Permissions/, f)
      assert_match(/include Guachiman::Params/, f)
      assert_match(/initialize current_user/, f)
    end
  end
end<commit_msg>fix test to reflect template change<commit_after>require 'test_helper'
require 'rails/generators/test_case'
require 'generators/guachiman/install/install_generator'

class InstallGeneratorTest < Rails::Generators::TestCase
  DESTINATION = File.expand_path File.join(File.dirname(__FILE__), '..', '..', 'tmp')
  FileUtils.mkdir_p DESTINATION unless Dir.exists? DESTINATION

  destination DESTINATION

  tests Guachiman::Generators::InstallGenerator
  setup :prepare_destination

  def prepare_destination
    FileUtils.rm_r    "#{DESTINATION}/app" if Dir.exists? "#{DESTINATION}/app"
    FileUtils.mkdir_p "#{DESTINATION}/app"
    FileUtils.mkdir_p "#{DESTINATION}/app/models"
  end

  test 'create permission' do
    run_generator

    assert_file 'app/models/permission.rb' do |f|
      assert_match(/class Permission/, f)
      assert_match(/include Guachiman::Permissions/, f)
      assert_match(/include Guachiman::Params/, f)
      assert_match(/initialize user, request/, f)
    end
  end
end
{'fraction_non_alphanumeric': 0.11302584896097313, 'fraction_numerical': 0.0, 'mean_word_length': 4.6239316239316235, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2127751', 'n_tokens_mistral': 636, 'n_tokens_neox': 617, 'n_words': 125}