spec fixing

This commit is contained in:
2018-01-29 15:15:55 -03:00
parent 9fd3df3da9
commit c9df6464f0
4 changed files with 11 additions and 4 deletions
+1
View File
@@ -17,6 +17,7 @@ group :development, :test do
gem 'spring'
gem 'spring-commands-rspec'
gem 'semantic-ui-sass'
gem 'foundation-rails', '~> 5.4'
gem "select2-rails"
#gem 'carrierwave'
#gem 'fog-aws'
+2 -1
View File
@@ -1,7 +1,8 @@
module CoreExtensions
module Time
module EpochWeek
EPOCH_BASE = -262800 # ::Time.at(0).utc.beginning_of_week # MONDAY!!!!!
#EPOCH_BASE = -262800 # ::Time.at(0).utc.beginning_of_week # MONDAY!!!!!
EPOCH_BASE = 259200 # -1*::Time.at(0).utc.beginning_of_week.to_i # MONDAY!!!!! '1969-12-29T00:00:00Z'.to_time.to_i + Time::EPOCH_BASE should be zero
def epoch_week
((to_i + EPOCH_BASE) / 604800).floor
end
@@ -2,8 +2,9 @@
#= require jquery_ujs
#= require dunlop
#= require_directory .
# require foundation
# require select2
# test app is still foundation, until enough love from somebody to convert (or phase out foundation)
#= require foundation
#= require select2
$ ->
$(document).foundation()
$(document).find('select.smart-select').select2()
@@ -1,6 +1,10 @@
require 'rails_helper'
RSpec.describe Time do #epoch_week
it "has a proper bias for making the monday of the epoch time the base unit" do
('1969-12-29T00:00:00Z'.to_time.to_i + Time::EPOCH_BASE).should be_zero
end
expectations = {
'2017-01-01' => 2452, # year 2016, week 52
'2020-12-24' => 2660, # year 2020, week 52
@@ -12,7 +16,7 @@ RSpec.describe Time do #epoch_week
}
expectations.each do |time, expected_epoch_week|
it "has the proper epoch_week for #{time}" do
time.to_time.epoch_week.should eq expected_epoch_week
"#{time}T00:00:00Z".to_time.epoch_week.should eq expected_epoch_week
end
end
end