Sha256: 77565a021c91f7d642ec34d7f2dffac765cbaf5ee96c8ac35366ff914d0f6dd6

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

describe Conekta::DiscountLine do
  include_context "API 2.0.0"
  include_context "order"

  let(:discount_lines) do
    [
      {
        code: "Cupon de descuento",
        type:        "loyalty",
        amount:      10
      },
      {
        code: "Cupon de descuento",
        type:        "loyalty",
        amount:      5
      }
    ]
  end

  let(:order) do
    Conekta::Order.create(order_data.merge(discount_lines: discount_lines))
  end

  let(:discount_line) { order.discount_lines.first }

  context "deleting discount lines" do
    it "successful discount line delete" do
      discount_line.delete

      expect(discount_line.deleted).to eq(true)
    end
  end

  context "updating discount lines" do
    it "successful discount line update" do
      discount_line.update(amount: 11)

      expect(discount_line.amount).to eq(11)
    end

    it "unsuccessful discount line update" do
      expect {
        discount_line.update(amount: -1)
      }.to raise_error(Conekta::ErrorList)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
conekta-2.0.0 spec/conekta/2.0.0/discount_line_spec.rb
conekta-1.1.3 spec/conekta/2.0.0/discount_line_spec.rb
conekta-1.1.2 spec/conekta/2.0.0/discount_line_spec.rb
conekta-1.1.1 spec/conekta/2.0.0/discount_line_spec.rb
conekta-1.1.0 spec/conekta/2.0.0/discount_line_spec.rb