Created
April 10, 2015 15:51
-
-
Save thiagofm/3dd44f4d4eebbbfea088 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require "active_support/core_ext" | |
def bookable? booked_day, now | |
now <= cancellable_until(booked_day) | |
end | |
def cancellable_until booked_day | |
booked_day + 2.days + 12.hours | |
end | |
describe "bookable?" do | |
it "books before in time" do | |
booked_day = Time.new(2015, 04, 10) | |
now = Time.new(2015, 04, 12, 11, 59, 00) | |
expect(bookable?(booked_day, now)).to be true | |
end | |
it "books on time" do | |
booked_day = Time.new(2015, 04, 10) | |
now = Time.new(2015, 04, 12, 12, 00, 00) | |
expect(bookable?(booked_day, now)).to be true | |
end | |
it "doesn't books after time" do | |
booked_day = Time.new(2015, 04, 10) | |
now = Time.new(2015, 04, 12, 12, 01, 00) | |
expect(bookable?(booked_day, now)).to be false | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment