<commit_before>require 'spec_helper'

shared_examples 'should not be captured' do
  it 'should not be captured' do
    payment.should_not_receive(:capture!)
    subject.try_capture(payment)
  end
end

describe PaymentMethod::MercadoPagoManual do
  let (:payment) { create :mp_manual_payment }
  subject { payment.payment_method }

  before(:each) { mock_authenticate subject.preferred_client_id, subject.preferred_client_secret }

  context 'with a pending money request' do
    before(:each) { mock_get_money_request payment.source.mercado_pago_id, 'pending' }
    include_examples 'should not be captured'
  end

  context 'with an accepted money request' do
    before(:each) { mock_get_money_request payment.source.mercado_pago_id, 'accepted' }

    context 'with a pending mercado pago payment' do
      before(:each) { mock_get_payment_status 'pending', payment.source.external_reference }
      include_examples 'should not be captured'
    end

    context 'with an approved mercado pago payment' do
      before(:each) { mock_get_payment_status 'approved', payment.source.external_reference }
      it 'should be captured' do
        payment.should_receive(:capture!)
        subject.try_capture(payment)
      end
    end
  end
end<commit_msg>Fix wrong call<commit_after>require_relative '../../spec_helper.rb'

shared_examples 'should not be captured' do
  it 'should not be captured' do
    payment.should_not_receive(:capture!)
    subject.try_capture(payment)
  end
end

describe PaymentMethod::MercadoPagoManual do
  let (:payment) { create :mp_manual_payment }
  subject { payment.payment_method }

  before(:each) { mock_authenticate subject.preferred_client_id, subject.preferred_client_secret }

  context 'with a pending money request' do
    before(:each) { mock_get_money_request payment.source.mercado_pago_id, 'pending' }
    include_examples 'should not be captured'
  end

  context 'with an accepted money request' do
    before(:each) { mock_get_money_request payment.source.mercado_pago_id, 'accepted' }

    context 'with a pending mercado pago payment' do
      before(:each) { mock_get_payment_status payment.source.external_reference, 'pending' }
      include_examples 'should not be captured'
    end

    context 'with an approved mercado pago payment' do
      before(:each) { mock_get_payment_status payment.source.external_reference, 'approved' }
      it 'should be captured' do
        payment.should_receive(:capture!)
        subject.try_capture(payment)
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.0803960396039604, 'fraction_numerical': 0.0, 'mean_word_length': 4.2625, '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': '3101126', 'n_tokens_mistral': 767, 'n_tokens_neox': 733, 'n_words': 201}