Ruby 断言数组是用minitest排序的
我需要能够使用ruby编写一个minitest测试,该测试断言给定数组是由asc或desc排序的 我的代码不完整,如下所示:Ruby 断言数组是用minitest排序的,ruby,minitest,Ruby,Minitest,我需要能够使用ruby编写一个minitest测试,该测试断言给定数组是由asc或desc排序的 我的代码不完整,如下所示: it "can order an array by asc order" do assert_equal tested_array, sorted_array end 你可以这样写: test "array should be sorted asc" do sorted_array = tested_array.sort assert_equal t
it "can order an array by asc order" do
assert_equal tested_array, sorted_array
end
你可以这样写:
test "array should be sorted asc" do
sorted_array = tested_array.sort
assert_equal tested_array, sorted_array, "Array sorted"
end
与
desc
相同,但要编写tested\u array.sort.reverse
而不是tested\u array.sort
您的问题是什么,能否提供一个代码示例?欢迎使用堆栈溢出。我们想看看你的尝试。所以,这不是一个“给我代码”的网站,而是一个“帮助我修复代码”,你的努力是非常重要的。请阅读“”和“”。@我编辑了这个问题。谢谢