Skip to content

Commit

Permalink
test: Remove dependency on timecop gem
Browse files Browse the repository at this point in the history
Use ActiveSupport::Testing::TimeHelpers instead
  • Loading branch information
hasghari committed Aug 18, 2024
1 parent aa8b80b commit 5fb25a8
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 12 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ gem 'rails-controller-testing'
gem 'rspec-rails'
gem 'shoulda-matchers'
gem 'sqlite3', '~> 1.7'
gem 'timecop'
2 changes: 0 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ GEM
stringio (3.1.1)
strscan (3.1.0)
thor (1.3.1)
timecop (0.9.10)
timeout (0.4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
Expand Down Expand Up @@ -275,7 +274,6 @@ DEPENDENCIES
rspec-rails
shoulda-matchers
sqlite3 (~> 1.7)
timecop

BUNDLED WITH
2.3.15
1 change: 0 additions & 1 deletion gemfiles/rails_6.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ gem "rails-controller-testing"
gem "rspec-rails"
gem "shoulda-matchers"
gem "sqlite3", "~> 1.7"
gem "timecop"
gem "railties", "~> 6.1.0"
gem "net-smtp", require: false
gem "base64", require: false
Expand Down
1 change: 0 additions & 1 deletion gemfiles/rails_7.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ gem "rails-controller-testing"
gem "rspec-rails"
gem "shoulda-matchers"
gem "sqlite3", "~> 1.7"
gem "timecop"
gem "railties", "~> 7.0.0"
gem "base64", require: false
gem "bigdecimal", require: false
Expand Down
1 change: 0 additions & 1 deletion gemfiles/rails_7.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ gem "rails-controller-testing"
gem "rspec-rails"
gem "shoulda-matchers"
gem "sqlite3", "~> 1.7"
gem "timecop"
gem "railties", "~> 7.1.0"

gemspec path: "../"
1 change: 0 additions & 1 deletion gemfiles/rails_7.2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ gem "rails-controller-testing"
gem "rspec-rails"
gem "shoulda-matchers"
gem "sqlite3", "~> 1.7"
gem "timecop"
gem "railties", "~> 7.2.0"

gemspec path: "../"
4 changes: 2 additions & 2 deletions spec/clearance/session_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'spec_helper'

describe Clearance::Session do
before { Timecop.freeze }
after { Timecop.return }
before { freeze_time }
after { unfreeze_time }

let(:session) { Clearance::Session.new(env_without_remember_token) }
let(:user) { create(:user) }
Expand Down
6 changes: 3 additions & 3 deletions spec/requests/token_expiration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
describe "Token expiration" do
describe "after signing in" do
before do
Timecop.freeze
freeze_time
create_user_and_sign_in
@initial_cookies = remember_token_cookies
end

after do
Timecop.return
unfreeze_time
end

it "should have a remember_token cookie with a future expiration" do
Expand All @@ -25,7 +25,7 @@
create_user_and_sign_in
@initial_cookies = remember_token_cookies

Timecop.travel(1.minute.from_now) do
travel_to(1.minute.from_now) do
get root_path
@followup_cookies = remember_token_cookies
end
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Dir[File.expand_path("spec/support/**/*.rb")].each { |f| require f }

RSpec.configure do |config|
config.include ActiveSupport::Testing::TimeHelpers
config.include FactoryBot::Syntax::Methods
config.infer_spec_type_from_file_location!
config.order = :random
Expand Down

0 comments on commit 5fb25a8

Please sign in to comment.