mirror of
https://github.com/jekyll/jekyll.git
synced 2026-01-06 21:54:09 -05:00
Fix flaky test that depends on current minute (#9889)
Merge pull request 9889
This commit is contained in:
committed by
GitHub
parent
a1a42bdb5c
commit
e91ed76d97
@@ -363,7 +363,21 @@ end
|
||||
#
|
||||
|
||||
Then(%r!^I should see today's time in "(.*)"$!) do |file|
|
||||
step %(I should see "#{seconds_agnostic_time(Time.now)}" in "#{file}")
|
||||
seconds = 3
|
||||
build_time = Time.now
|
||||
content = file_contents(file)
|
||||
date_time_pattern = /(\d{4}-\d{2}-\d{2}\s\d+:\d{2}:\d{2})/
|
||||
match_data = content.match(date_time_pattern)
|
||||
expect(match_data).not_to be_nil, "No date-time pattern found in #{file}"
|
||||
date_time_str = match_data.captures
|
||||
file_time = Time.parse("#{date_time_str}")
|
||||
time_difference = (build_time - file_time).abs
|
||||
expect(time_difference).to be <= seconds, <<~MSG
|
||||
Expected time in #{file} to be within #{seconds} seconds of build time.
|
||||
Build time: #{build_time}
|
||||
File time: #{file_time}
|
||||
Difference: #{time_difference} seconds
|
||||
MSG
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
@@ -145,25 +145,6 @@ end
|
||||
|
||||
#
|
||||
|
||||
def seconds_agnostic_datetime(datetime = Time.now)
|
||||
date, time, zone = datetime.to_s.split(" ")
|
||||
time = seconds_agnostic_time(time)
|
||||
|
||||
[
|
||||
Regexp.escape(date),
|
||||
"#{time}:\\d{2}",
|
||||
Regexp.escape(zone),
|
||||
].join("\\ ")
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def seconds_agnostic_time(time)
|
||||
time = time.strftime("%H:%M:%S") if time.is_a?(Time)
|
||||
hour, minutes, = time.split(":")
|
||||
"#{hour}:#{minutes}"
|
||||
end
|
||||
|
||||
# Helper method for Windows
|
||||
def dst_active?
|
||||
config = Jekyll.configuration("quiet" => true)
|
||||
|
||||
Reference in New Issue
Block a user