Sha256: 8d5b221db4bf77c31f43e691033ba7f2420e661b00ad6a54e4b162a1387d68d8

Contents?: true

Size: 1.62 KB

Versions: 6

Compression:

Stored size: 1.62 KB

Contents

require 'spec_helper'

describe Spree::PaymentMethod::Check do
  let(:order) { create(:order) }
  subject { described_class.new }

  context "#can_capture?" do
    let(:payment) { create(:payment, order: order, state: state) }

    context "with payment in state checkout" do
      let(:state) { "checkout" }

      it "returns true" do
        expect(subject.can_capture?(payment)).to be_truthy
      end
    end

    context "with payment in state pending" do
      let(:state) { "pending" }

      it "returns true" do
        expect(subject.can_capture?(payment)).to be_truthy
      end
    end

    context "with payment in state failed" do
      let(:state) { "failed" }

      it "returns false" do
        expect(subject.can_capture?(payment)).to be_falsy
      end
    end
  end

  context "#can_void?" do
    let(:payment) { create(:payment, order: order, state: state) }

    context "with payment in state checkout" do
      let(:state) { "checkout" }

      it "returns true" do
        expect(subject.can_void?(payment)).to be_truthy
      end
    end

    context "with payment in state void" do
      let(:state) { "void" }

      it "returns false" do
        expect(subject.can_void?(payment)).to be_falsy
      end
    end
  end

  context "#capture" do
    it "succeds" do
      expect(subject.capture).to be_success
    end
  end

  context "#cancel" do
    it "returns nil" do
      expect(subject.cancel).to be_nil
    end
  end

  context "#void" do
    it "succeds" do
      expect(subject.void).to be_success
    end
  end

  context "#credit" do
    it "succeds" do
      expect(subject.credit).to be_success
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
solidus_core-2.3.1 spec/models/spree/payment_method/check_spec.rb
solidus_core-2.3.0 spec/models/spree/payment_method/check_spec.rb
solidus_core-2.3.0.rc3 spec/models/spree/payment_method/check_spec.rb
solidus_core-2.3.0.rc2 spec/models/spree/payment_method/check_spec.rb
solidus_core-2.3.0.rc1 spec/models/spree/payment_method/check_spec.rb
solidus_core-2.3.0.beta1 spec/models/spree/payment_method/check_spec.rb