Revert to #readlines#join, but enclose it in a function
This is necessary to preserve the handling of \r\n and \n line endings.
This commit is contained in:
parent
be54303fa9
commit
89f0d69b07
|
@ -142,19 +142,19 @@ Then /^the (.*) directory should exist$/ do |dir|
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see "(.*)" in "(.*)"$/ do |text, file|
|
Then /^I should see "(.*)" in "(.*)"$/ do |text, file|
|
||||||
assert Regexp.new(text).match(File.read(file))
|
assert Regexp.new(text).match(read_file(file))
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see exactly "(.*)" in "(.*)"$/ do |text, file|
|
Then /^I should see exactly "(.*)" in "(.*)"$/ do |text, file|
|
||||||
assert_equal text, File.read(file).strip
|
assert_equal text, read_file(file).strip
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should not see "(.*)" in "(.*)"$/ do |text, file|
|
Then /^I should not see "(.*)" in "(.*)"$/ do |text, file|
|
||||||
assert_no_match Regexp.new(text), File.read(file)
|
assert_no_match Regexp.new(text), read_file(file)
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see escaped "(.*)" in "(.*)"$/ do |text, file|
|
Then /^I should see escaped "(.*)" in "(.*)"$/ do |text, file|
|
||||||
assert Regexp.new(Regexp.escape(text)).match(File.read(file))
|
assert Regexp.new(Regexp.escape(text)).match(read_file(file))
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^the "(.*)" file should exist$/ do |file|
|
Then /^the "(.*)" file should exist$/ do |file|
|
||||||
|
@ -166,9 +166,9 @@ Then /^the "(.*)" file should not exist$/ do |file|
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see today's time in "(.*)"$/ do |file|
|
Then /^I should see today's time in "(.*)"$/ do |file|
|
||||||
assert_match Regexp.new(Regexp.escape(Time.now.to_s)), File.read(file)
|
assert_match Regexp.new(Regexp.escape(Time.now.to_s)), read_file(file)
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see today's date in "(.*)"$/ do |file|
|
Then /^I should see today's date in "(.*)"$/ do |file|
|
||||||
assert_match Regexp.new(Date.today.to_s), File.read(file)
|
assert_match Regexp.new(Date.today.to_s), read_file(file)
|
||||||
end
|
end
|
||||||
|
|
|
@ -35,5 +35,11 @@ def location(folder, direction)
|
||||||
[before || '.', after || '.']
|
[before || '.', after || '.']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def read_file(path)
|
||||||
|
File.open(path) do |file|
|
||||||
|
file.readlines.join # avoid differences with \n and \r\n line endings
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# work around "invalid option: --format" cucumber bug (see #296)
|
# work around "invalid option: --format" cucumber bug (see #296)
|
||||||
Test::Unit.run = true if RUBY_VERSION < '1.9'
|
Test::Unit.run = true if RUBY_VERSION < '1.9'
|
||||||
|
|
Loading…
Reference in New Issue