Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for issues #36, #45 and #83 (bug in business_days.before/after) #120

Merged
merged 4 commits into from Feb 3, 2016

Conversation

dugjason
Copy link
Contributor

Changed

  • Changes in BusinessTime.before and BusinessTime.after methods to ensure that we return the time at the beginning of the business day when working with a Time or DateTime object. How the method handles Date objects is unaffected
  • Minor refactoring suggested by Rubocop.

New Example Output

irb(main):001:0> require 'business_time'
=> true
irb(main):002:0> 1.business_day.before Date.parse("Thursday October 15th, 2015")
=> Wed, 14 Oct 2015
irb(main):003:0> 1.business_day.before Time.parse("Thursday October 15th, 2015, 15:00")
=> 2015-10-14 15:00:00 +0100
irb(main):004:0> 1.business_day.before Time.parse("Thursday October 15th, 2015, 05:10")
=> 2015-10-13 09:00:00 +0100
irb(main):005:0> 1.business_day.before DateTime.parse("Thursday October 15th, 2015, 05:10")
=> Tue, 13 Oct 2015 09:00:00 +0000

Test cases

Failing test cases were added before the work was completed:

➜  business_time git:(feature/issue-83) ✗ rake
business_time 0.7.4 built to pkg/business_time-0.7.4.gem.
business_time 0.7.4 built to pkg/business_time-0.7.4.gem.
business_time (0.7.4) installed.
/Users/jason/.rbenv/versions/2.2.3/bin/ruby -I"lib" -I"/Users/jason/.rbenv/versions/2.2.3/lib/ruby/2.2.0" "/Users/jason/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/rake_test_loader.rb" "test/test*.rb"
Run options: --seed 45686

# Running:

............................................................................................................................F.FF........F........

Finished in 0.198888s, 729.0535 runs/s, 1096.0943 assertions/s.

  1) Failure:
business days::with a standard Time object#test_0012_should return a business hour when adding one business day from after business hours [/Users/jason/Code/business_time/test/test_business_days.rb:90]:
Expected: 2015-10-16 09:00:00 +0100
  Actual: 2015-10-15 21:54:00 +0100


  2) Failure:
business days::with a standard Time object#test_0011_should return a business hour when adding one business day from before business hours [/Users/jason/Code/business_time/test/test_business_days.rb:83]:
Expected: 2015-10-15 09:00:00 +0100
  Actual: 2015-10-15 01:54:00 +0100


  3) Failure:
business days::with a standard Time object#test_0013_should return a business hour when subtracting one business day from before business hours [/Users/jason/Code/business_time/test/test_business_days.rb:97]:
Failed assertion, no message given.


  4) Failure:
business days::with a standard Time object#test_0014_should return a business hour when subtracting one business day from after business hours [/Users/jason/Code/business_time/test/test_business_days.rb:105]:
Failed assertion, no message given.

145 runs, 218 assertions, 4 failures, 0 errors, 0 skips

@bokmann
Copy link
Owner

bokmann commented Feb 3, 2016

Wow! For some reason github wasn't sending me emails, I just checked the project, and found this present! I'm sorry it waited so long; for my purposes this gem just hums along and I never really worry about it.

bokmann added a commit that referenced this pull request Feb 3, 2016
Fixes for issues #36, #45 and #83 (bug in business_days.before/after)
@bokmann bokmann merged commit 731dac8 into bokmann:develop Feb 3, 2016
@dugjason dugjason deleted the feature/issue-83 branch March 7, 2018 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants