Skip to content

Commit

Permalink
Use rails in_time_zone
Browse files Browse the repository at this point in the history
  • Loading branch information
gangelo committed Dec 23, 2023
1 parent e74a166 commit 2c7aed1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions spec/dsu/features/dsu_add_features_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

context "when 'dsu add DESCRIPTION' is called" do
before do
allow(Time).to receive(:now).and_return(Time.parse('2023-06-16'))
freeze_time_at(time_string: '2023-06-16')
end

let(:args) { ['add', entry_description] }
Expand Down Expand Up @@ -75,7 +75,7 @@
before do
with_entries

allow(Time).to receive(:now).and_return(Time.parse('2023-06-16'))
freeze_time_at(time_string: '2023-06-16')
end

let(:args) { ['add', '--tomorrow', entry_description] }
Expand Down Expand Up @@ -104,7 +104,7 @@
before do
with_entries

allow(Time).to receive(:now).and_return(Time.parse('2023-06-16'))
freeze_time_at(time_string: '2023-06-16')
end

let(:args) { ['add', '--yesterday', entry_description] }
Expand Down Expand Up @@ -133,7 +133,7 @@
before do
with_entries

allow(Time).to receive(:now).and_return(Time.parse('2023-06-16'))
freeze_time_at(time_string: '2023-06-16')
end

let(:args) { ['add', '--today', entry_description] }
Expand Down
4 changes: 4 additions & 0 deletions spec/support/time_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
# This module provides methods to help with Time
# objects
module TimeHelpers
def freeze_time_at(time_string:)
allow(Time).to receive(:now).and_return(Time.parse(time_string).in_time_zone)
end

def today_yyyymmdd_string
to_yyyymmdd_string(Time.now.in_time_zone)
end
Expand Down

0 comments on commit 2c7aed1

Please sign in to comment.