Get some nice Regexp which is agnostic about the seconds.
This commit is contained in:
parent
35336bfff4
commit
aa6ee14fb7
|
@ -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|
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Reference in New Issue