<commit_before>require 'spec_helper'

shared_examples 'Refund API' do

  it "refunds a stripe charge item" do
    charge = Stripe::Charge.create(
      amount: 999,
      currency: 'USD',
      card: 'card_token_abcde',
      description: 'card charge'
    )

    charge = charge.refund(amount: 999)

    expect(charge.refunded).to eq(true)
    expect(charge.refunds.data.first.amount).to eq(999)
    expect(charge.amount_refunded).to eq(999)
  end

  it "creates a stripe refund with the charge ID" do
    charge = Stripe::Charge.create(
      amount: 999,
      currency: 'USD',
      card: 'card_token_abcde',
      description: 'card charge'
    )
    refund = charge.refund

    expect(charge.id).to match(/^test_ch/)
    expect(refund.id).to eq(charge.id)
  end

  it "creates a stripe refund with a refund ID" do<commit_msg>Live test stripe refund id<commit_after>require 'spec_helper'

shared_examples 'Refund API' do

  it "refunds a stripe charge item" do
    charge = Stripe::Charge.create(
      amount: 999,
      currency: 'USD',
      card: 'card_token_abcde',
      description: 'card charge'
    )

    charge = charge.refund(amount: 999)

    expect(charge.refunded).to eq(true)
    expect(charge.refunds.data.first.amount).to eq(999)
    expect(charge.amount_refunded).to eq(999)
  end

  it "creates a stripe refund with the charge ID", :live => true do
    charge = Stripe::Charge.create(
      amount: 999,
      currency: 'USD',
      card: stripe_helper.generate_card_token,
      description: 'card charge'
    )
    refund = charge.refund

    expect(charge.id).to match(/^(test_)?ch/)
    expect(refund.id).to eq(charge.id)
  end

  it "creates a stripe refund with a refund ID" do
{'fraction_non_alphanumeric': 0.11475409836065574, 'fraction_numerical': 0.01756440281030445, 'mean_word_length': 3.0593824228028503, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '5099263', 'n_tokens_mistral': 621, 'n_tokens_neox': 561, 'n_words': 149}