Skip to content

Commit

Permalink
Merge pull request #166 from jaredbeck/also_test_zero_days_before
Browse files Browse the repository at this point in the history
Also test 0.business_days/hours.before
  • Loading branch information
bokmann authored Jun 30, 2017
2 parents 52d979e + cdb82e4 commit 6315bc8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
7 changes: 7 additions & 0 deletions test/test_business_days.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
assert_equal expected, after
end

it "should pick previous working day when subtracting zero days on the weekend" do
first = Time.parse("January 30th, 2016, 12:33 pm")
after = 0.business_days.before(first)
expected = Time.parse("January 29th, 2016, 12:33 pm")
assert_equal expected, after
end

it "should move forward one week when adding 5 business days" do
first = Time.parse("April 9th, 2010, 12:33 pm")
after = 5.business_days.after(first)
Expand Down
17 changes: 12 additions & 5 deletions test/test_business_hours.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@
assert_equal expected, after
end

it "should pick previous working day when subtracting zero hours on the weekend" do
first = Time.parse("January 30th, 2016, 12:33 pm")
after = 0.business_hours.before(first)
expected = Time.parse("January 29th, 2016, 17:00 pm")
assert_equal expected, after
end

it "take into account a weekend when adding an hour, using the common interface #since" do
friday_afternoon = Time.parse("April 9th 2010, 4:50 pm")
monday_morning = 1.business_hour.since(friday_afternoon)
Expand Down Expand Up @@ -274,7 +281,7 @@
assert_equal monday, -15.business_hours.before(saturday)
end
end

it "responds appropriatly to <" do
assert 5.business_hours < 10.business_hours
assert !(10.business_hours < 5.business_hours)
Expand All @@ -285,7 +292,7 @@
assert -5.business_hours < 5.business_hours
assert !(5.business_hours < -5.business_hours)
end

it "responds appropriatly to >" do
assert !(5.business_hours > 10.business_hours)
assert 10.business_hours > 5.business_hours
Expand All @@ -296,7 +303,7 @@
assert !(-5.business_hours > 5.business_hours)
assert 5.business_hours > -5.business_hours
end

it "responds appropriatly to ==" do
assert 5.business_hours == 5.business_hours
assert 10.business_hours != 5.business_hours
Expand All @@ -306,7 +313,7 @@

assert -5.business_hours != 5.business_hours
end

it "won't compare hours and days" do
assert_raises ArgumentError do
5.business_hours < 5.business_days
Expand All @@ -315,6 +322,6 @@
-5.business_hours < -5.business_days
end
end

end
end

0 comments on commit 6315bc8

Please sign in to comment.