Complete the code to define a simple test case in Minitest.
class CalculatorTest < [1] def test_addition assert_equal 4, 2 + 2 end end
In Minitest, test classes inherit from Minitest::Test to define test cases.
Complete the code to write an example group in RSpec.
RSpec.describe Calculator do it '[1]' do expect(2 + 2).to eq(4) end end
RSpec uses descriptive strings inside it blocks to explain the behavior being tested.
Fix the error in the Minitest assertion syntax.
def test_subtraction [1] 2, 5 - 3 end
Minitest uses assert_equal(expected, actual) for equality checks.
Fill both blanks to complete the RSpec expectation syntax.
expect([1]).to [2](5)
In RSpec, expect(value).to eq(expected) checks if value equals expected.
Fill all three blanks to write a Minitest setup method and test.
class UserTest < Minitest::Test def [1] @user = User.new(name: 'Alice') end def [2] assert_equal '[3]', @user.name end end
The setup method runs before each test. Test methods start with test_. The assertion checks the user's name.
