Get some nice Regexp which is agnostic about the seconds.

This commit is contained in:
Parker Moore 2013-09-27 15:38:38 -04:00
parent 35336bfff4
commit aa6ee14fb7
2 changed files with 11 additions and 1 deletions

View File

@ -170,7 +170,7 @@ Then /^the "(.*)" file should not exist$/ do |file|
end
Then /^I should see today's time in "(.*)"$/ do |file|
assert_match Regexp.new(Regexp.escape(Time.now.to_s)), File.open(file).readlines.join
assert_match Regexp.new(seconds_agnostic_time(Time.now)), File.open(file).readlines.join
end
Then /^I should see today's date in "(.*)"$/ do |file|

View File

@ -40,5 +40,15 @@ def location(folder, direction)
[before || '.', after || '.']
end
def seconds_agnostic_time(datetime = Time.now)
pieces = datetime.to_s.split(" ")
time = "#{pieces[1].split(':').first}:#{pieces[1].split(':')[1]}:\\d{2}"
[
Regexp.escape(pieces[0]),
time,
Regexp.escape(pieces.last)
].join("\\ ")
end
# work around "invalid option: --format" cucumber bug (see #296)
Test::Unit.run = true if RUBY_VERSION < '1.9'