Bird
0
0

Identify the error in this Ruby test code:

medium📝 Debug Q6 of 15
Ruby - Testing with RSpec and Minitest
Identify the error in this Ruby test code:
require 'minitest/autorun'

class TestCalc < Minitest::Test
  def test_sum
    assert_equal 10, 5 + 4
  end
end
AThe expected value is incorrect
BThe test method name is invalid
CMissing 'require' statement
DNo error, test will fail
Step-by-Step Solution
Solution:
  1. Step 1: Check the assertion values

    The test expects 10 but 5 + 4 equals 9, so the expected value is wrong.
  2. Step 2: Verify other code parts

    Test method name and require statement are correct; test will fail due to wrong expected value.
  3. Final Answer:

    The expected value is incorrect -> Option A
  4. Quick Check:

    Wrong expected value causes failure [OK]
Quick Trick: Check expected vs actual values carefully [OK]
Common Mistakes:
  • Assuming test method name is wrong
  • Forgetting require statement
  • Thinking test passes despite wrong expected

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes