Sha256: dd557c9f89a61dd234351a1f5988574d944c551f4371a7d2a97f33b925fb21e0
Contents?: true
Size: 1.63 KB
Versions: 7
Compression:
Stored size: 1.63 KB
Contents
require_relative '../../test_helper' module PagarMe class PlanTest < PagarMeTestCase should 'be able to create a plan' do plan = PagarMe::Plan.create plan_params assert_plan_created plan end should 'be able to update plan' do plan = PagarMe::Plan.create plan_params assert_plan_created plan plan.name = 'plano bronze' plan.save assert_equal plan.name, 'plano bronze' end should 'be able to search by anything' do assert_plan_created PagarMe::Plan.create(plan_params) # find_by_hash is possibly consistent, wait to try to ensure!!! sleep 1 found_plans = PagarMe::Plan.find_by trial_days: 5 assert found_plans.size > 0 found_plans.each do |plan| assert_equal plan.trial_days, 5 end end should 'validate plan amount' do exception = assert_raises(PagarMe::ValidationError){ Plan.create amount: -1 } assert_has_error_param exception, 'amount' end should 'validate plan days' do exception = assert_raises(PagarMe::ValidationError){ Plan.create amount: 1000, days: -1 } assert_has_error_param exception, 'days' end should 'validate plan with missing name' do exception = assert_raises(PagarMe::ValidationError){ Plan.create amount: 1000, days: 20 } assert_has_error_param exception, 'name' end should 'not be possible to edit days' do plan = Plan.create amount: 1000, days: 20, name: 'Plano Platinum' exception = assert_raises(PagarMe::ValidationError) do plan.days = 30 plan.save end assert_has_error_param exception, 'days' end end end
Version data entries
7 entries across 7 versions & 1 rubygems