Sha256: f5f7f84d262841b8bd5020a06ed7bb84c30160d1709dfd30980ab809316357e6

Contents?: true

Size: 1.77 KB

Versions: 6

Compression:

Stored size: 1.77 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '../unit_test_helper'))

describe BraintreeRails::Discount do
  before do
    stub_braintree_request(:get, '/discounts', :body => fixture('discounts.xml'))
  end

  describe '#initialize' do
    it 'should wrap a Braintree::Discount' do
      braintree_discount = Braintree::Discount.all.find { |d| d.id == 'discount_id' }
      discount = BraintreeRails::Discount.new(braintree_discount)

      discount.persisted?.must_equal true
      discount.never_expires?.must_equal braintree_discount.never_expires?
      BraintreeRails::Discount.attributes.each do |attribute|
        discount.send(attribute).must_equal braintree_discount.send(attribute)
      end
    end

    it 'should load a Braintree::Discount by id' do
      braintree_discount = Braintree::Discount.all.find { |d| d.id == 'discount_id' }
      discount = BraintreeRails::Discount.new('discount_id')

      discount.persisted?.must_equal true
      BraintreeRails::Discount.attributes.each do |attribute|
        discount.send(attribute).must_equal braintree_discount.send(attribute)
      end
    end

    it 'should find a Braintree::Discount' do
      braintree_discount = Braintree::Discount.all.find { |d| d.id == 'discount_id' }
      discount = BraintreeRails::Discount.find('discount_id')

      discount.persisted?.must_equal true
      BraintreeRails::Discount.attributes.each do |attribute|
        discount.send(attribute).must_equal braintree_discount.send(attribute)
      end
    end
  end

  describe 'all' do
    it 'should wrap all discounts' do
      braintree_discounts = Braintree::Discount.all
      discounts = BraintreeRails::Discount.all

      discounts.must_be_kind_of(Enumerable)
      discounts.size.must_equal braintree_discounts.size
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
braintree-rails-1.2.3 test/unit/braintree_rails/discount_test.rb
braintree-rails-1.2.2 test/unit/braintree_rails/discount_test.rb
braintree-rails-1.2.1 test/unit/braintree_rails/discount_test.rb
braintree-rails-1.2.0 test/unit/braintree_rails/discount_test.rb
braintree-rails-1.1.0 test/unit/braintree_rails/discount_test.rb
braintree-rails-1.0.0 test/unit/braintree_rails/discount_test.rb