Sha256: 7ff4ddfd35d3a0c3e56afe88e7e2717936e1b5fa4977e1e5c7321c41d3a0ab16

Contents?: true

Size: 1.52 KB

Versions: 13

Compression:

Stored size: 1.52 KB

Contents

require File.expand_path('../../test_helper', __FILE__)

module Payjp
  class PlanTest < Test::Unit::TestCase
    should "create should return a new plan" do
      @mock.expects(:post).once.returns(test_response(test_plan))
      plan = Payjp::Plan.create({
        :amount => 500,
        :currency => 'jpy',
        :interval => 'month',
        :trial_days => 30
      })
      assert_equal 'pln_test_plan', plan.id
    end

    should "retrieve should retrieve plan" do
      @mock.expects(:get).once.returns(test_response(test_plan))
      plan = Payjp::Plan.retrieve('pln_test_plan')
      assert_equal 'pln_test_plan', plan.id
    end

    should "plans should be deletable" do
      @mock.expects(:delete).once.returns(test_response(test_plan({ :deleted => true })))
      plan = Payjp::Plan.new("test_plan")
      plan.delete
      assert plan.deleted
    end

    should "plans should be listable" do
      @mock.expects(:get).once.returns(test_response(test_plan_array))
      plans = Payjp::Plan.all
      assert plans.data.is_a? Array
      plans.each do |plan|
        assert plan.is_a?(Payjp::Plan)
      end
    end

    should "plans should be updateable" do
      @mock.expects(:get).once.returns(test_response(test_plan({ :name => 'current plan' })))
      @mock.expects(:post).once.returns(test_response(test_plan({ :name => 'new plan' })))
      plan = Payjp::Plan.new("test_plan").refresh
      assert_equal 'current plan', plan.name
      plan.name = 'new plan'
      plan.save
      assert_equal 'new plan', plan.name
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
payjp-0.0.16 test/payjp/plan_test.rb
payjp-0.0.14 test/payjp/plan_test.rb
payjp-0.0.13 test/payjp/plan_test.rb
payjp-0.0.12 test/payjp/plan_test.rb
payjp-0.0.10 test/payjp/plan_test.rb
payjp-0.0.9 test/payjp/plan_test.rb
payjp-0.0.8 test/payjp/plan_test.rb
payjp-0.0.7 test/payjp/plan_test.rb
payjp-0.0.6 test/payjp/plan_test.rb
payjp-0.0.5 test/payjp/plan_test.rb
payjp-0.0.4 test/payjp/plan_test.rb
payjp-0.0.3 test/payjp/plan_test.rb
payjp-0.0.2 test/payjp/plan_test.rb