require "spec_helper"

describe Time do
  describe ".beginning_of_timehop_day" do
    subject { time.beginning_of_timehop_day }
    context "after 5am" do
      let(:time) { Time.parse("2011-11-07 15:15:33") }
      let(:beginning_of_timehop_day) { Time.parse("2011-11-07 5:00:00") }
      it { should be_within(1.second).of(beginning_of_timehop_day) }
    end
    context "before 5am" do
      let(:time) { Time.parse("2011-11-07 3:15:33") }
      let(:beginning_of_timehop_day) { Time.parse("2011-11-06 5:00:00") }
      it { should be_within(1.second).of(beginning_of_timehop_day) }
    end
  end
  describe ".end_of_timehop_day" do
    subject { time.end_of_timehop_day }
    context "after 5am" do
      let(:time) { Time.parse("2011-11-07 15:15:33") }
      let(:end_of_timehop_day) { Time.parse("2011-11-08 4:59:59") }
      it { should be_within(1.second).of(end_of_timehop_day) }
    end
    context "before 5am" do
      let(:time) { Time.parse("2011-11-07 3:15:33") }
      let(:end_of_timehop_day) { Time.parse("2011-11-07 4:59:59") }
      it { should be_within(1.second).of(end_of_timehop_day) }
    end
  end
end
