Sha256: 593b219b75842336a2c2604813b12fc723344973cf3e5a425314daaffeee9b33
Contents?: true
Size: 1.51 KB
Versions: 2
Compression:
Stored size: 1.51 KB
Contents
require "assert" require 'scmd/command' class CommandTests < Assert::Context desc "a command" setup do @success_cmd = Scmd::Command.new("echo hi") @failure_cmd = Scmd::Command.new("cd /path/that/does/not/exist") end subject { @success_cmd } should have_readers :cmd_str, :pid, :exitcode, :stdout, :stderr should have_instance_methods :run, :run! should "know and return its cmd string" do assert_equal "echo hi", subject.cmd_str assert_equal "echo hi", subject.to_s end should "default its result values" do assert_nil subject.pid assert_nil subject.exitcode assert_equal '', subject.stdout assert_equal '', subject.stderr end should "run the command and set appropriate result data" do @success_cmd.run assert_not_nil @success_cmd.pid assert_equal 0, @success_cmd.exitcode assert @success_cmd.success? assert_equal 'hi', @success_cmd.stdout assert_equal '', @success_cmd.stderr @failure_cmd.run assert_not_nil @failure_cmd.pid assert_not_equal 0, @failure_cmd.exitcode assert_not @failure_cmd.success? assert_equal '', @failure_cmd.stdout assert_not_equal '', @failure_cmd.stderr end should "raise an exception on `run!` and a non-zero exitcode" do assert_raises Scmd::Command::Failure do @failure_cmd.run! end end should "return itself on `run`, `run!`" do assert_equal @success_cmd, @success_cmd.run assert_equal @success_cmd, @success_cmd.run! assert_equal @failure_cmd, @failure_cmd.run end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
scmd-1.0.0 | test/command_tests.rb |
scmd-0.0.1 | test/command_tests.rb |