In Rspec how do I test the number of rows that are in a CSV file?
I have created a CSV file in a mutation. I am able to test the output of the CSV by checking if certain text is included. However, I would like to be able to test the number of rows that are in the output.
Please find an example of what I have tested so far below which passes:
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
gives you the total number of rows
so expect(outcome.lines.count).to eq(10)
should help
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.