Skip to content

Commit

Permalink
Remove unnecessary dependency on the timecop gem (#205)
Browse files Browse the repository at this point in the history
* remove timecop gem

* add AS timehelpers

* update tests
  • Loading branch information
luciagirasoles authored Nov 5, 2023
1 parent e24a009 commit 229ed2b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ group :test do
gem 'factory_bot_rails', '~> 6.2.0'
gem 'selenium-webdriver', '~> 4.8.1'
gem 'shoulda-matchers', '~>5.3.0'
gem 'timecop', '~> 0.9.6'
gem 'webdrivers', '~>5.2.0'
end

Expand Down
2 changes: 0 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@ GEM
railties (>= 6.0.0)
thor (1.2.2)
tilt (2.2.0)
timecop (0.9.6)
timeout (0.4.0)
trailblazer-option (0.1.2)
truncate_html (0.9.3)
Expand Down Expand Up @@ -436,7 +435,6 @@ DEPENDENCIES
shoulda-matchers (~> 5.3.0)
slack-ruby-client (~> 2.0.0)
stimulus-rails (~> 1.2.1)
timecop (~> 0.9.6)
truncate_html (~> 0.9.3)
turbo-rails (~> 1.4.0)
tzinfo-data
Expand Down
4 changes: 3 additions & 1 deletion spec/controllers/api/events_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@

# Some of these tests may be time-dependent
# so we mock the time the tests are run
Timecop.freeze(DateTime.new(2022, 3, 30))
travel_to(DateTime.new(2022, 3, 30))
end

after { travel_back }

describe 'GET #past' do
before do
july_meetup = create(:event, title: 'July Meetup', date: DateTime.new(2021, 7, 31, 16).utc)
Expand Down
2 changes: 2 additions & 0 deletions spec/support/time_helpers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# frozen_string_literal: true
RSpec.configure { |config| config.include ActiveSupport::Testing::TimeHelpers }
8 changes: 4 additions & 4 deletions spec/tasks/job_board/digest_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
after(:each) { Rake::Task['job_board:digest'].reenable }

context 'when it is Monday' do
before { Timecop.travel(Time.now.last_week(:monday)) }
after { Timecop.return }
before { travel_to(Time.now.last_week(:monday)) }
after { travel_back }

it 'posts job listings to Slack' do
client = stub_slack_client
Expand All @@ -23,8 +23,8 @@
end

context 'when it is not Monday' do
before { Timecop.travel(Time.now.last_week(:tuesday)) }
after { Timecop.return }
before { travel_to(Time.now.last_week(:tuesday)) }
after { travel_back }

it 'does not post job listings to Slack' do
client = stub_slack_client
Expand Down

0 comments on commit 229ed2b

Please sign in to comment.