Merge pull request #1493 from maul-esel/feature-improvements
Improve features / tests code
This commit is contained in:
commit
fb6f8c1ff1
|
@ -157,19 +157,19 @@ Then /^the (.*) directory should not exist$/ do |dir|
|
|||
end
|
||||
|
||||
Then /^I should see "(.*)" in "(.*)"$/ do |text, file|
|
||||
assert Regexp.new(text).match(File.open(file).readlines.join)
|
||||
assert_match Regexp.new(text), file_contents(file)
|
||||
end
|
||||
|
||||
Then /^I should see exactly "(.*)" in "(.*)"$/ do |text, file|
|
||||
assert_equal text, File.open(file).readlines.join.strip
|
||||
assert_equal text, file_contents(file).strip
|
||||
end
|
||||
|
||||
Then /^I should not see "(.*)" in "(.*)"$/ do |text, file|
|
||||
assert_no_match Regexp.new(text), File.read(file)
|
||||
assert_no_match Regexp.new(text), file_contents(file)
|
||||
end
|
||||
|
||||
Then /^I should see escaped "(.*)" in "(.*)"$/ do |text, file|
|
||||
assert Regexp.new(Regexp.escape(text)).match(File.open(file).readlines.join)
|
||||
assert_match Regexp.new(Regexp.escape(text)), file_contents(file)
|
||||
end
|
||||
|
||||
Then /^the "(.*)" file should +exist$/ do |file|
|
||||
|
@ -181,9 +181,9 @@ 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(Regexp.escape(Time.now.to_s)), file_contents(file)
|
||||
end
|
||||
|
||||
Then /^I should see today's date in "(.*)"$/ do |file|
|
||||
assert_match Regexp.new(Date.today.to_s), File.open(file).readlines.join
|
||||
assert_match Regexp.new(Date.today.to_s), file_contents(file)
|
||||
end
|
||||
|
|
|
@ -40,5 +40,11 @@ def location(folder, direction)
|
|||
[before || '.', after || '.']
|
||||
end
|
||||
|
||||
def file_contents(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)
|
||||
Test::Unit.run = true if RUBY_VERSION < '1.9'
|
||||
|
|
Loading…
Reference in New Issue