This repository has been archived on 2020-02-24. You can view files and clone it, but cannot push or open issues or pull requests.
plsql-spec-example/spec/award_bonus_spec.rb
2020-01-16 14:11:30 +03:00

34 lines
1.0 KiB
Ruby

# load 'award_bonus' procedure into the database
require 'award_bonus'
describe "Award bonus" do
include EmployeeFactory
[ [1000, 1234.55, 0.10, 1123.46],
[nil, 1234.56, 0.10, 123.46],
[1000, 1234.54, 0.10, 1123.45]
].each do |salary, sales_amt, commission_pct, result|
it "should calculate base salary #{salary.inspect} + sales amount #{sales_amt} * commission percentage #{commission_pct} = salary #{result.inspect}" do
employee = create_employee(
:commission_pct => commission_pct,
:salary => salary
)
plsql.award_bonus(employee[:employee_id], sales_amt)
expect(get_employee(employee[:employee_id])[:salary]).to eq result
end
end
it "should raise ORA-06510 exception if commission percentage is missing" do
salary, sales_amt, commission_pct = 1000, 1234.55, NULL
employee = create_employee(
:commission_pct => commission_pct,
:salary => salary
)
expect {
plsql.award_bonus(employee[:employee_id], sales_amt)
}.to raise_error(/ORA-06510/)
end
end