gpt4 book ai didi

ruby - RSpec : How to test file parser

转载 作者:数据小太阳 更新时间:2023-10-29 08:05:24 26 4
gpt4 key购买 nike

我是 ruby​​ 和 rspec 的新手,我想知道如何测试必须解析文件的类。这是我计划测试的功能:

def self.get_description(event_code)
# search through a file for the event_code and return
# the associated description field
end

在生产中,我将硬编码文件的路径。我应该如何控制来自 rspec 的文件内容?

最佳答案

创建一些解析 Tempfiles that you create 的规范包含有效和无效输入,并确保解析函数返回预期结果(或异常)。

关于ruby - RSpec : How to test file parser,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10518662/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com