Bird
0
0

What is wrong with this Ruby test code snippet?

medium📝 Debug Q7 of 15
Ruby - Testing with RSpec and Minitest
What is wrong with this Ruby test code snippet?
require 'minitest/autorun'

class TestMath < Minitest::Test
  def test_multiply
    assert_equal 20, 4 * 5
ATest method name does not start with 'test_'
BIncorrect assertion syntax
CWrong require statement
DMissing 'end' keyword for method and class
Step-by-Step Solution
Solution:
  1. Step 1: Check code completeness

    The method and class are not closed with 'end' keywords, causing syntax errors.
  2. Step 2: Verify other parts

    Assertion syntax and require statement are correct; method name starts with 'test_'.
  3. Final Answer:

    Missing 'end' keyword for method and class -> Option D
  4. Quick Check:

    Missing 'end' causes syntax error [OK]
Quick Trick: Always close methods and classes with 'end' [OK]
Common Mistakes:
  • Forgetting 'end' keywords
  • Miswriting assertion syntax
  • Wrong require statement

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes