6. Modules and Mixins
Activity 6.01: Implementing Categories on the Voting Application Program
Solution
- We'll begin by first using the code from the previous chapter and writing some tests.
- Write a new test for
VotingMachine
to add a category:require "minitest/autorun" require 'minitest/stub_any_instance' require_relative "../models/voting_machine" class TestVotingMachine < Minitest::Test def test_add_category machine = VotingMachine.new(1, 1) machine.add_category("TestCategory") assert_equal machine.categories, ["TestCategory"] machine.add_category("TestCategory2") assert_equal machine.categories, ["TestCategory", "TestCategory2"] machine.add_category("TestCategory") assert_equal machine.categories...