Created
September 19, 2011 08:53
-
-
Save sixtyfive/1226165 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# activity.rb | |
def full_duration | |
return (duration_in_minutes.to_f / 60).round(1) | |
end | |
# activity_spec.rb | |
describe "full_duration()" do | |
context "when duration_in_minutes is saved in the database" do | |
let(:duration_in_minutes) { mock "duration in minutes" } | |
before :each do | |
activity.stub :duration_in_minutes => duration_in_minutes | |
end | |
it "gets the duration_in_minutes from the database" do | |
activity.should_receive :duration_in_minutes | |
activity.full_duration | |
end | |
it "converts the minutes into fractional hours" do | |
activity.duration_in_minutes.should_receive(:to_f).should_receive('/').should_receive(:round).with(1) | |
activity.full_duration | |
end | |
it "returns the duration in fractional hours" do | |
activity.full_duration.should equal (duration_in_minutes.to_f / 60).round(1) | |
end | |
end | |
context "started_on and ended_on refer to days only" do | |
end | |
context "started_on and ended_on refer to times" do | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment