Sha256: 394b4f0805627a306bbc59c39923bab51dc64e018ccc0d0fa4a8cec92d8da510

Contents?: true

Size: 1.56 KB

Versions: 8

Compression:

Stored size: 1.56 KB

Contents

# encoding: utf-8
require_relative '../test_helper'

module PagarMe
  class PlanTest < Test::Unit::TestCase
    should 'be able to create a plan' do
      plan = test_plan
      plan.create
      test_plan_response(plan)
    end

    should 'be able to update plan' do
      plan = test_plan
      plan.create
      plan.name = "plano silver"
      plan.save
      assert plan.name == 'plano silver'
    end

    should 'be able to create with unformatted amount' do
      plan = test_plan
      plan.amount = 'R$ 10.00'
      plan.create
      assert plan.amount == 1000
    end

    should 'validate plan' do
      exception = assert_raises PagarMeError do
        plan = Plan.new({
          :amount => -1
        })
        plan.create
      end
      assert exception.errors.first.parameter_name == 'amount'
      exception = assert_raises PagarMeError do
        plan = Plan.new({
          :amount => 1000,
          :days => -1,
        })
        plan.create
      end
      assert exception.errors.first.parameter_name == 'days'

      exception = assert_raises PagarMeError do
        plan = Plan.new({
          :amount => 1000,
          :days => 30,
        })
        plan.create
      end
      assert exception.errors.first.parameter_name == 'name'
      exception = assert_raises PagarMeError do
        plan = Plan.new({
          :amount => 1000,
          :days => 30,
          :name => "Plano Silver"
        })
        plan.create
        plan.days = 'Plano gold'
        plan.save
      end
      assert exception.errors.first.parameter_name == 'days'
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pagarme-1.8 test/pagarme/plan.rb
pagarme-1.7 test/pagarme/plan.rb
pagarme-1.5 test/pagarme/plan.rb
pagarme-1.4 test/pagarme/plan.rb
pagarme-1.3 test/pagarme/plan.rb
pagarme-1.2 test/pagarme/plan.rb
pagarme-1.1 test/pagarme/plan.rb
pagarme-1.0 test/pagarme/plan.rb