Ruby 使用rspec测试可执行文件
有什么方法可以使用rspec测试通用可执行文件吗? 我喜欢rspec中定义测试的方式 类似于Ruby 使用rspec测试可执行文件,ruby,rspec,tdd,Ruby,Rspec,Tdd,有什么方法可以使用rspec测试通用可执行文件吗? 我喜欢rspec中定义测试的方式 类似于 it "should return error" do program.output.should == "Error in program" end Rspec 3.0输出匹配器: 期望{its_my_mthd}输出(“its the message for the world”)。输出到stdout 期望{its_my_mthd}.输出(“它的魔鬼消息错误”)。到\u stderr Min
it "should return error" do
program.output.should == "Error in program"
end
Rspec 3.0输出匹配器:
期望{its_my_mthd}输出(“its the message for the world”)。输出到stdout
期望{its_my_mthd}.输出(“它的魔鬼消息错误”)。到\u stderr
Minitest还有一种称为capture_io的功能:
out, err = capture_io do
my_method
end
assert_equals "its the message for the world", out
assert_equals "its devils message error", err
它的mthd是什么?如何为我的系统命令指定参数?这也适用于在backticks中执行的shell命令。