我有这个代码(在撬):
class Hash
def invert_by_array
each.with_object({}) {|(key,value), obj|
value.each do |element|
obj[element] = key
end
}
end
end
require 'minitest/spec'
describe "invert_by_array" do
it "should use the array element as keys" do
{'foo' => %w(bar baz)}.invert_by_array.must_equal({'bar' => 'foo', 'baz' => 'foo'})
end
end
如何从编辑底部运行测试 - 基本上将上面的内容复制/粘贴到 readline?