作者热门文章
- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我是 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/
我是一名优秀的程序员,十分优秀!