在 Rspec 中,我如何测试 CSV 文件中的行数?
我已经在 mutation 中创建了一个 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)
关于ruby-on-rails - Rspec:测试 CSV 输出中的行数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37815072/