<commit_before>require 'spec_helper'

module Core
  module Interactors
    module Customer
      RSpec.describe Updater do
        describe '#call' do
          let(:attributes) do
            {
              first_name: 'Phil',
              email: '<EMAIL>',
              password: 'password',
              post_code: 'NE1 6EE'
            }
          end
          let!(:user){ User.create!(attributes) }
          subject{ described_class.new(user) }

          context 'when customer exists' do
            it 'updates attributes' do
              user.first_name = 'Philip'

              subject = described_class.new(user)
              subject.call

              customer = Core::Registry::Repository[:customer].customers.first
              expect(customer[:first_name]).to eql('Philip')
            end
          end

          context 'when customer does not exist' do
            let(:user){ User.new(customer_id: 'customer_123') }
            it 'raises an exception' do
              expect{ subject.call }.to raise_error
            end
          end
        end
      end
    end
  end
end
<commit_msg>extract to use test fixture<commit_after>require 'spec_helper'

module Core
  module Interactors
    module Customer
      RSpec.describe Updater do
        describe '#call' do
          let(:attributes) do
            {
              first_name: 'Phil',
              email: '<EMAIL>',
              password: 'password',
              post_code: 'NE1 6EE'
            }
          end
          let!(:user){ User.create!(attributes) }
          subject{ described_class.new(user) }

          context 'when customer exists' do
            let(:first_name){ 'Philip' }

            it 'updates attributes' do
              user.first_name = first_name

              subject = described_class.new(user)
              subject.call

              customer = Core::Registry::Repository[:customer].customers.first
              expect(customer[:first_name]).to eql(first_name)
            end
          end

          context 'when customer does not exist' do
            let(:user){ User.new(customer_id: 'customer_123') }
            it 'raises an exception' do
              expect{ subject.call }.to raise_error
            end
          end
        end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.08637152777777778, 'fraction_numerical': 0.004340277777777778, 'mean_word_length': 1.5301866081229418, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1783793', 'n_tokens_mistral': 603, 'n_tokens_neox': 584, 'n_words': 158}