summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2014-05-22 20:50:08 -0600
committermo khan <mo@mokhan.ca>2014-05-22 20:50:08 -0600
commit39806c8827f616e08236bab0571822457d187558 (patch)
treee3c4c5e9b3b72a87c0df3ef9f837f6a246af0e88
parent9f7e55b3d8e295d731e238d8a35e0810e11055c9 (diff)
split out tests into separate contexts.
-rw-r--r--spec/unit/employee_spec.rb59
1 files changed, 47 insertions, 12 deletions
diff --git a/spec/unit/employee_spec.rb b/spec/unit/employee_spec.rb
index 7acf580..60fbbaa 100644
--- a/spec/unit/employee_spec.rb
+++ b/spec/unit/employee_spec.rb
@@ -2,22 +2,57 @@ require "spec_helper"
describe Employee do
let(:sut) { Employee.new }
+ let(:today) { Clock.today }
- context "when issued a grant that vests annually" do
- it "computes the value of the grant after 6 months" do
+ describe "#value_of_unvested_units_at" do
+ context "when issued a grant that vests quarterly" do
+ before :each do
+ sut.issue_grant(80_000.dollars, 1.00.dollar)
+ end
+
+ context "before anything has vested" do
+ let(:six_months_from_now) { today + (365/2) }
+
+ before :each do
+ Clock.stub(:now).and_return(six_months_from_now)
+ end
+
+ it "computes the value of the grant after 6 months" do
+ sut.value_of_unvested_units_at(10.dollars).should == 800_000.dollars
+ end
+ end
+
+ context "after one vesting period" do
+ let(:one_year_from_now) { today + 365 }
+ let(:portion_to_vest) { 1.0/4.0 }
+
+ before :each do
+ Clock.stub(:now).and_return(one_year_from_now)
+ sut.grant_for(today).vest_at(10.dollars, portion_to_vest)
+ end
+
+ it "computes the correct value of unvested units" do
+ sut.value_of_unvested_units_at(10.dollars).should == 600_000.dollars
+ end
+ end
+ end
+ end
+
+ describe "#value_of_vested_units_at" do
+ before :each do
sut.issue_grant(80_000.dollars, 1.00.dollar)
- current_price = 10.dollars
- sut.value_of_unvested_units_at(current_price)
end
- it "computes the value of the grant after one year" do
- today = Clock.today
- one_year_from_now = today + 365
- sut.issue_grant(80_000, 1.00)
- Clock.stub(:now).and_return(one_year_from_now)
- sut.grant_for(today).vest_at(10.dollars, 1.0/4.0)
- sut.value_of_vested_units_at(10.dollars).should == 200_000.dollars
- sut.value_of_unvested_units_at(10.dollars).should == 600_000.dollars
+ context "after one vesting period" do
+ let(:portion_to_vest) { 1.0/4.0 }
+
+ before :each do
+ sut.grant_for(today).vest_at(10.dollars, portion_to_vest)
+ end
+
+ it "computes the values of vested units after one vesting period" do
+ sut.value_of_vested_units_at(10.dollars).should == 200_000.dollars
+ end
end
end
end