0
0
Ruby on Railsframework~10 mins

Minitest vs RSpec in Ruby on Rails - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a simple test case in Minitest.

Ruby on Rails
class CalculatorTest < [1]
  def test_addition
    assert_equal 4, 2 + 2
  end
end
Drag options to blanks, or click blank then click option'
ARSpec::Core::ExampleGroup
BTest::Unit::TestCase
CActiveSupport::TestCase
DMinitest::Test
Attempts:
3 left
💡 Hint
Common Mistakes
Using RSpec class names in Minitest tests.
Confusing ActiveSupport::TestCase with Minitest::Test.
2fill in blank
medium

Complete the code to write an example group in RSpec.

Ruby on Rails
RSpec.describe Calculator do
  it '[1]' do
    expect(2 + 2).to eq(4)
  end
end
Drag options to blanks, or click blank then click option'
Aadds numbers correctly
Btest addition
Cshould add numbers
Dchecks addition
Attempts:
3 left
💡 Hint
Common Mistakes
Using imperative phrases like 'test addition' instead of descriptive behavior.
Not using a string inside the it block.
3fill in blank
hard

Fix the error in the Minitest assertion syntax.

Ruby on Rails
def test_subtraction
  [1] 2, 5 - 3
end
Drag options to blanks, or click blank then click option'
Aassert_equal
Bshould
Cexpect
Dassert
Attempts:
3 left
💡 Hint
Common Mistakes
Using RSpec syntax like 'expect' in Minitest.
Using 'assert' without '_equal' for equality checks.
4fill in blank
hard

Fill both blanks to complete the RSpec expectation syntax.

Ruby on Rails
expect([1]).to [2](5)
Drag options to blanks, or click blank then click option'
Acalculator.add(2, 3)
Beq
Cbe
Dequal
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'be' matcher incorrectly for equality.
Putting the expected value inside expect().
5fill in blank
hard

Fill all three blanks to write a Minitest setup method and test.

Ruby on Rails
class UserTest < Minitest::Test
  def [1]
    @user = User.new(name: 'Alice')
  end

  def [2]
    assert_equal '[3]', @user.name
  end
end
Drag options to blanks, or click blank then click option'
Asetup
Btest_name
CAlice
Dinitialize
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'initialize' instead of 'setup' for test preparation.
Not prefixing test methods with 'test_'.
Using wrong expected value in assertion.