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
ActiveSupport::Testing::TimeHelpers#to_travel does not support today
#25848
Labels
Comments
I tried to reproduce your case. begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'byebug'
gem 'rspec-rails'
end
require 'active_support/testing/time_helpers'
require 'active_support/core_ext/object/blank'
require 'minitest/autorun'
RSpec.configure do |config|
config.include ActiveSupport::Testing::TimeHelpers
end
RSpec.describe "Date" do
it "Changes current time to given time" do
travel_to(Date.parse("monday")) do
expect(Date.today).to eql Date.parse('monday') #=> false
end
end
end Specs are passing and while debbuging |
Yes, same here. It may be something in your application. |
Let me try reproducing it on a new app. Thanks for your time guys! |
For me, this returns the current friday instead of the same day 🤔 #!/usr/bin/env ruby
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'byebug'
gem 'rspec-rails'
end
require 'active_support/testing/time_helpers'
require 'active_support/core_ext/object/blank'
require 'minitest/autorun'
RSpec.configure do |config|
config.include ActiveSupport::Testing::TimeHelpers
end
RSpec.describe "Date" do
it "Changes current time to given time" do
travel_to('2021-02-12') do
expect(Date.parse('Friday')).to eq Date.new(2021, 2, 12) #=> false
end
end
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps to reproduce
Expected behavior
the
today
method should return the date we just travelled toActual behavior
today
gives the real time, and ignores the current time that travel_to is using.System configuration
Rails version: 5.0.0
Ruby version: 2.3.1
The text was updated successfully, but these errors were encountered: