features/step_definitions/steps.rb in hoc-0.9.0 vs features/step_definitions/steps.rb in hoc-0.10.0

- old
+ new

@@ -1,6 +1,6 @@ -# Copyright (c) 2014-2019 Yegor Bugayenko +# Copyright (c) 2014-2023 Yegor Bugayenko # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the 'Software'), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell @@ -24,17 +24,17 @@ require 'English' Before do @cwd = Dir.pwd @dir = Dir.mktmpdir('test') - FileUtils.mkdir_p(@dir) unless File.exist?(@dir) + FileUtils.mkdir_p(@dir) Dir.chdir(@dir) end After do Dir.chdir(@cwd) - FileUtils.rm_rf(@dir) if File.exist?(@dir) + FileUtils.rm_rf(@dir) end Given(/^It is Unix$/) do pending if Gem.win_platform? end @@ -56,20 +56,16 @@ @stdout = `ruby -I#{home}/lib #{home}/bin/hoc #{arg}` @exitstatus = $CHILD_STATUS.exitstatus end Then(/^Stdout contains "([^"]*)"$/) do |txt| - unless @stdout.include?(txt) - raise "STDOUT doesn't contain '#{txt}':\n\n--------\n#{@stdout}\n--------\n" - end + raise "STDOUT doesn't contain '#{txt}':\n\n--------\n#{@stdout}\n--------\n" unless @stdout.include?(txt) end Then(/^Exit code is zero$/) do raise "Non-zero exit code #{@exitstatus}" unless @exitstatus.zero? end Given(/^I have a "([^"]*)" file with content:$/) do |file, text| FileUtils.mkdir_p(File.dirname(file)) unless File.exist?(file) - File.open(file, 'w') do |f| - f.write(text) - end + File.write(file, text) end