Sha256: d9e53ce69e8a2f323d13129ea35d8779c8da1d2b98d442638bfc287ba358ccda
Contents?: true
Size: 1.73 KB
Versions: 1
Compression:
Stored size: 1.73 KB
Contents
require File.dirname(__FILE__) + '/test_helper' require 'rscm/command_line' module RSCM class DifftoolTest < Test::Unit::TestCase def setup_dir(prefix) @dir = RSCM.new_temp_dir(prefix) @stdout = "#{@dir}/stdout" @stderr = "#{@dir}/stderr" @prompt = "#{File.expand_path(@dir)} #{Platform.user}$" File.delete @stdout if File.exist? @stdout File.delete @stderr if File.exist? @stderr end def test_should_write_to_both_files_when_both_files_specified_and_no_block setup_dir(method_name) CommandLine.execute("echo \"<hello\" && echo world", {:dir => @dir, :stdout => @stdout, :stderr => @stderr}) assert_match(/.* echo \"<hello\"\s*\n.?\<hello.?\s*\n.* echo world\s*\nworld/n, File.open(@stdout).read) assert_match(/.* echo \"<hello\"\s*\n.* echo world\s*/n, File.open(@stderr).read) end def test_should_not_write_to_stdout_file_when_no_stdout_specified setup_dir(method_name) orgout = STDOUT.dup STDOUT.reopen(@stdout) CommandLine.execute("echo hello", {:dir => @dir, :stderr => @stderr}) STDOUT.reopen(orgout) assert_equal("#{@prompt} echo hello\nhello", File.open(@stdout).read.strip) assert_equal("#{@prompt} echo hello", File.open(@stderr).read.strip) end def test_should_only_write_command_to_stdout_when_block_specified setup_dir(method_name) CommandLine.execute("echo hello", {:dir => @dir, :stdout => @stdout, :stderr => @stderr}) do |io| assert_equal("hello", io.read.strip) end assert_match(/.* echo hello\s*\[output captured and therefore not logged\]/n, File.open(@stdout).read.strip) assert_equal("#{@prompt} echo hello", File.open(@stderr).read.strip) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rscm-0.5.0 | test/rscm/command_line_test.rb |