[英]Rspec: test number of rows in CSV output
在Rspec中,如何测试CSV文件中的行数?
我在变异中创建了一个CSV文件。 我可以通过检查是否包含某些文本来测试CSV的输出。 但是,我希望能够测试输出中的行数。
请查看我到目前为止测试的示例 ,其中包含以下内容:
describe "#execute" do
it "creates a CSV for the specified content" do
outcome = mutation.run(mutation_params)
expect(outcome.result).to include("Name")
end
end
你可以算一下换行符:
expect(outcome.result.split("\n").size).to eq(10)
outcome.lines.count
为您提供总行数
所以expect(outcome.lines.count).to eq(10)
应该有所帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.