7. Introduction to Ruby Gems
Activity 7.01: Presenting Voting Data in CSV Format Using Ruby Gems
Solution
- Download the
votes.csv
file from https://packt.live/2OzNN6a. Place this undertest/fixtures
. The CSV file will contain the following data:category,votee,count VoteCategoryA,Chris Jones,23 VoteCategoryA,Susie Bennet,29 VoteCategoryB,Allan Green,33 VoteCategoryB,Tony Bennet,23
- We'll start with our
VoteImporter
service object. Test whether it imports data from the CSV and perform a few basic checks to ensure that the content is what we're expecting. Create thetest_vote_importer.rb
file in thetests
folder with the following code:require "minitest/autorun" require 'minitest/stub_any_instance' require_relative "../services/vote_importer" class TestVoteImporter < Minitest::Test def test_perform # Import vote data from our tests/fixtures/votes.csv file filepath = &apos...