test/spec/plans_spec.rb in openpay-1.0.10 vs test/spec/plans_spec.rb in openpay-2.0.0b
- old
+ new
@@ -15,25 +15,29 @@
@subscriptions=@openpay.create(:subscriptions)
end
+=begin
+
after(:all) do
@plans.delete_all
end
+=end
+
it 'has all required methods' do
%w(all each create get list delete).each do |meth|
expect(@plans).to respond_to(meth)
end
end
describe '.create' do
it 'creates a merchant plan' do
- plan_hash= FactoryGirl.build(:plan, repeat_every: 5)
+ plan_hash= FactoryBot.build(:plan, repeat_every: 5)
plan=@plans.create(plan_hash)
#validates
expect(@plans.get(plan['id'])['repeat_every']).to be 5
@@ -47,11 +51,11 @@
describe 'get' do
it 'gets a merchant plan' do
#creates a plan
- plan_hash= FactoryGirl.build(:plan, repeat_every: 5, amount: 500)
+ plan_hash= FactoryBot.build(:plan, repeat_every: 5, amount: 500)
plan=@plans.create(plan_hash)
#validates
expect(@plans.get(plan['id'])['repeat_every']).to be 5
expect(@plans.get(plan['id'])['amount']).to be_within(0.1).of(500)
@@ -81,11 +85,11 @@
end
describe '.list' do
it 'list all plans given the filter' do
#creates a plan
- plan_hash= FactoryGirl.build(:plan, repeat_every: 5, amount: 500)
+ plan_hash= FactoryBot.build(:plan, repeat_every: 5, amount: 500)
plan=@plans.create(plan_hash)
search_params = OpenpayUtils::SearchParams.new
search_params.limit = 1
expect(@plans.list(search_params).size).to eq 1
@@ -98,51 +102,51 @@
describe '.update' do
it 'updates an existing customer plan' do
#creates a plan
- plan_hash= FactoryGirl.build(:plan, trial_days: 10)
+ plan_hash= FactoryBot.build(:plan, trial_days: 10)
plan=@plans.create(plan_hash)
expect(plan['trial_days']).to be 10
- plan_hash= FactoryGirl.build(:plan, trial_days: 100)
+ plan_hash= FactoryBot.build(:plan, trial_days: 100)
plan=@plans.update(plan_hash, plan['id'])
expect(plan['trial_days']).to be 100
#cleanup
@plans.delete(plan['id'])
end
it 'fails to update an non existing customer plan' do
- plan_hash= FactoryGirl.build(:plan, trial_days: 100)
+ plan_hash= FactoryBot.build(:plan, trial_days: 100)
#validates
expect { @plans.update(plan_hash, '111111') }.to raise_exception RestClient::ResourceNotFound
begin
@plans.update(plan_hash, '111111')
rescue RestClient::ResourceNotFound => e
expect(e.http_body).to be_a String
- expect(e.message).to match '404 Resource Not Found'
+ expect(e.message).to include("404")
end
end
end
- describe '.each' do
+ skip '.each' do
it 'iterates over all customer plans' do
#creates a plan
- plan_hash= FactoryGirl.build(:plan, trial_days: 10)
+ plan_hash= FactoryBot.build(:plan, trial_days: 30)
plan=@plans.create(plan_hash)
plan1=@plans.create(plan_hash)
plan2=@plans.create(plan_hash)
expect(@plans.all.size).to be_a Integer
@plans.each do |plan|
- expect(plan['name']).to match 'Curso de ingles'
+ expect(plan['name']).to match 'TODO INCLUIDO'
@plans.delete(plan['id'])
end
expect(@plans.all.size).to be_a Integer