<commit_before>require_relative '../rspec_helper'

describe Smartcoin::Customer do
  before(:each) do
    Smartcoin.api_key('pk_test_3ac0794848c339')
    Smartcoin.api_secret('sk_test_8bec997b7a0ea1')
  end

  it 'should create a customer' do
    customer_params = {email: "test_#{SecureRandom.hex(5)}<EMAIL>"}
    customer = Smartcoin::Customer.create(customer_params)
    expect(customer.email).to eq(customer_params[:email])
    expect(customer.default_card).to be_nil
  end

  it 'should retrieve a customer by id' do
    customer_params = {email: "test_#{SecureRandom.hex(5)}"}
    customer = Smartcoin::Customer.create(customer_params)
    retrieved_customer = Smartcoin::Customer.retrieve(customer.id)
    expect(retrieved_customer.email).to eq(customer_params[:email])
    expect(retrieved_customer.to_s).to eq(customer.to_s)
  end

  it 'should retrieve a customer by email' do
    customer_params = {email: "test_#{SecureRandom.hex(5)}<EMAIL>"}
    customer = Smartcoin::Customer.create(customer_params)
    retrieved_customer = Smartcoin::Customer.retrieve(customer.email)
    expect(retrieved_customer.email).to eq(customer_params[:email])
    expect(retrieved_customer.to_s).to eq(customer.to_s)
  end

  it 'should update a customer' do
    token_params = {number:  4242424242424242,
                        exp_month: 5,
                        exp_year: 2017,
                        cvc: '011',
                        name: '<NAME>'
                      }
    token = Smartcoin::Token.create(token_params)

    customer_params = {email: "test_#{SecureRandom.hex(5)}@<EMAIL>"}<commit_msg>BugFix: The test of retrieve Customer was creating the new one with email bad formatted<commit_after>require_relative '../rspec_helper'

describe Smartcoin::Customer do
  before(:each) do
    Smartcoin.api_key('pk_test_3ac0794848c339')
    Smartcoin.api_secret('sk_test_8bec997b7a0ea1')
  end

  it 'should create a customer' do
    customer_params = {email: "test_#{SecureRandom.hex(5)}<EMAIL>"}
    customer = Smartcoin::Customer.create(customer_params)
    expect(customer.email).to eq(customer_params[:email])
    expect(customer.default_card).to be_nil
  end

  it 'should retrieve a customer by id' do
    customer_params = {email: "test_#{SecureRandom.hex(5)}<EMAIL>"}
    customer = Smartcoin::Customer.create(customer_params)
    retrieved_customer = Smartcoin::Customer.retrieve(customer.id)
    expect(retrieved_customer.email).to eq(customer_params[:email])
    expect(retrieved_customer.to_s).to eq(customer.to_s)
  end

  it 'should retrieve a customer by email' do
    customer_params = {email: "test_#{SecureRandom.hex(5)}<EMAIL>"}
    customer = Smartcoin::Customer.create(customer_params)
    retrieved_customer = Smartcoin::Customer.retrieve(customer.email)
    expect(retrieved_customer.email).to eq(customer_params[:email])
    expect(retrieved_customer.to_s).to eq(customer.to_s)
  end

  it 'should update a customer' do
    token_params = {number:  4242424242424242,
                        exp_month: 5,
                        exp_year: 2017,
                        cvc: '011',
                        name: '<NAME>'
                      }
    token = Smartcoin::Token.create(token_params)

    customer_params = {email: "test_#{SecureRandom.hex(5)}<EMAIL>"}
{'fraction_non_alphanumeric': 0.11421628189550426, 'fraction_numerical': 0.027946537059538274, 'mean_word_length': 3.6185133239831697, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '4017611', 'n_tokens_mistral': 1096, 'n_tokens_neox': 1023, 'n_words': 189}