Sha256: b23a021360ebc9f0336401c7b02302355075267dbabb6ec018d25a97a208f024

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

# encoding: utf-8
require 'spec_helper'

describe "Receipt", :vcr, class: Pin::Receipt do
  before(:each) do
    Pin::Base.new(ENV["PIN_SECRET"], :test)
    @charge = Pin::Charges.find("ch_0kdOMXP7gG0_W_Vh8qAWdA")
    @company_details = ["ABC Widgets", "123 Fake Street Melbourne","VIC 3000", "ABN: 12 345 678 910"]
    @receipt = Pin::Receipt.new(@charge, @company_details)
  end

  it "should generate an HTML receipt  given a charge" do
    @receipt.render().should include(@charge["token"])
  end

  it "should save an index.html file for the receipt" do
    # tmp folder not included in git repo - travis ci failing
    @receipt.save()
    File.read('tmp/receipt.html').should include(@charge["token"])
    File.delete('tmp/receipt.html')
  end

  it "should format a number as a currency" do
    expect @receipt.send(:number_to_currency, 1989, 'null').should match(/[$,£,€]\d{1,}[.]\d{2}/)
  end

  it "should print payment option information" do
    payment_options = {}
    payment_options["fee"] = {"name" => "late fee", "amount" => "$10.00"}
    payment_options["tax"] = {"name" => "GST", "amount" => "$10.00"}
    payment_options["discount"] = {"name" => "Member Discount", "amount" => "$10.00"}

    @detailed_receipt = Pin::Receipt.new(@charge, @company_details, nil, payment_options)
    expect @detailed_receipt.render().should include("GST")
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pin_up_receipts-1.1.0 spec/receipt_spec.rb