Sha256: c7736e26f278f75d655a7214f9d13a44c60384e1efb8c5353176cf4a64be8532

Contents?: true

Size: 1.54 KB

Versions: 9

Compression:

Stored size: 1.54 KB

Contents

require 'test_helper'

module RubyPsigate
  class RecurringItemTest < Test::Unit::TestCase
    
    def setup
      @recurring_item = RecurringItem.new
    end
    
    %w( product_id description quantity price tax1 tax2 cost ).each do |attribute|
      should "have getter/setter for #{attribute}" do
        getter = attribute.to_sym
        setter = "#{attribute}=".to_sym
        assert @recurring_item.respond_to?(getter)
        assert @recurring_item.respond_to?(setter)
      end
    end
    
    should "return a hash" do
      @expectation = {
        :ProductID => "Newspaper",
        :Description => "Toronto Star",
        :Quantity => 1,
        :Price => "25.00",
        :Tax1 => "2.00",
        :Tax2 => "1.25"
      }
      
      @recurring_item = RecurringItem.new(
        :product_id => "Newspaper",
        :description => "Toronto Star",
        :quantity => 1,
        :price => "25.00",
        :tax1 => "2.00",
        :tax2 => "1.25"
      )
      
      assert_equal @expectation, @recurring_item.to_hash
    end
    
    should "return a hash without nil values" do
      @expectation = {
        :ProductID => "Newspaper",
        :Description => "Toronto Star",
        :Quantity => "1",
        :Price => "25.00"
      }
      
      @recurring_item = RecurringItem.new(
        :product_id => "Newspaper",
        :description => "Toronto Star",
        :quantity => "1",
        :price => "25.00",
        :tax1 => nil,
        :tax2 => nil
      )
      
      assert_equal @expectation, @recurring_item.to_hash      
    end
    
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ruby_psigate-0.7.8 test/unit/recurring_item_test.rb
ruby_psigate-0.7.7 test/unit/recurring_item_test.rb
ruby_psigate-0.7.6 test/unit/recurring_item_test.rb
ruby_psigate-0.7.5 test/unit/recurring_item_test.rb
ruby_psigate-0.7.4 test/unit/recurring_item_test.rb
ruby_psigate-0.7.3 test/unit/recurring_item_test.rb
ruby_psigate-0.7.2 test/unit/recurring_item_test.rb
ruby_psigate-0.7.1 test/unit/recurring_item_test.rb
ruby_psigate-0.7 test/unit/recurring_item_test.rb