<commit_before># frozen_string_literal: true

require 'rails_helper'

RSpec.describe ExpensesHousingController, :member, type: :controller do
  let!(:current_app) do
    App.create!(attributes.merge(user: @member))
  end

  let(:attributes) do
    ExpensesHousing.attribute_names.map do |k|
      [k, App.columns_hash[k].type == :integer ? 123 : true]
    end.to_h
  end

  let(:step) do
    assigns(:step)
  end

  describe '#edit' do
    it 'assigns the attributes to the step' do
      get :edit

      expect(attributes.keys.map { |attr| [attr, step.send(attr)] }.to_h).to eq attributes
    end
  end

  describe '#update' do
    context 'with valid params' do
      let(:params) do
        {
          step: ExpensesHousing.attribute_names.map do |k|
            [k, App.columns_hash[k].type == :integer ? 321 : false]
          end.to_h
        }
      end
<commit_msg>a little refactor in test<commit_after># frozen_string_literal: true

require 'rails_helper'

RSpec.describe ExpensesHousingController, :member, type: :controller do
  let!(:current_app) do
    App.create!(attributes.merge(user: @member))
  end

  let(:attributes) do
    ExpensesHousing.attribute_names.map do |k|
      [k, integer_type?(k) ? 123 : true]
    end.to_h
  end

  def integer_type?(k)
    App.columns_hash[k].type == :integer
  end

  let(:step) do
    assigns(:step)
  end

  describe '#edit' do
    it 'assigns the attributes to the step' do
      get :edit

      expect(attributes.keys.map { |attr| [attr, step.send(attr)] }.to_h).to eq attributes
    end
  end

  describe '#update' do
    context 'with valid params' do
      let(:params) do
        {
          step: ExpensesHousing.attribute_names.map do |k|
            [k, integer_type?(k) ? 321 : false]
          end.to_h
        }
      end

{'fraction_non_alphanumeric': 0.11489124372559956, 'fraction_numerical': 0.006692693809258227, 'mean_word_length': 2.7375, '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': '4436205', 'n_tokens_mistral': 619, 'n_tokens_neox': 594, 'n_words': 157}