From e62ceaaab779fde10f7ae34a5a9eaa221d209ae5 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Thu, 7 Aug 2014 20:09:08 +0200 Subject: [PATCH] #5 fixed --- bin/pdd | 4 ++-- features/cli.feature | 4 ++-- features/step_definitions/steps.rb | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/pdd b/bin/pdd index ead2c3c..f60ad4e 100755 --- a/bin/pdd +++ b/bin/pdd @@ -38,6 +38,6 @@ end if opts.help? puts opts else - file = opts.file? ? opts[:file] : STDOUT - File.write(file, PDD::Base.new(opts).xml) + file = opts.file? ? File.new(opts[:file], 'w') : STDOUT + file << PDD::Base.new(opts).xml end diff --git a/features/cli.feature b/features/cli.feature index 7b0d283..d898ded 100644 --- a/features/cli.feature +++ b/features/cli.feature @@ -33,6 +33,6 @@ Feature: Command Line Processing ~~ and second ~~ """ - When I run bin/pdd with " " + When I run bin/pdd with "> out.xml" Then Exit code is zero - And Stdout contains "" + And XML file "out.xml" matches "/puzzles[count(puzzle)=1]" diff --git a/features/step_definitions/steps.rb b/features/step_definitions/steps.rb index 19c0d96..0a9dc0b 100644 --- a/features/step_definitions/steps.rb +++ b/features/step_definitions/steps.rb @@ -81,6 +81,7 @@ end Then(/^XML file "([^"]+)" matches "([^"]+)"$/) do |file, xpath| + fail "File #{file} doesn't exit" unless File.exist?(file) xml = Nokogiri::XML.parse(File.read(file)) if xml.xpath(xpath).empty? fail "XML file #{file} doesn't match \"#{xpath}\":\n#{xml}"