0
0
Ruby on Railsframework~20 mins

Minitest vs RSpec in Ruby on Rails - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Minitest vs RSpec Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Difference in Syntax Style Between Minitest and RSpec
Which of the following code snippets correctly shows how to write a simple test that checks if 2 + 2 equals 4 in Minitest and RSpec respectively?
A
Minitest: expect(2 + 2).to eq(4)
RSpec: assert_equal 4, 2 + 2
B
Minitest: test 'sum' do
  expect(2 + 2).to eq(4)
end
RSpec: it 'adds numbers' do
  assert_equal 4, 2 + 2
end
C
Minitest: assert_equal 4, 2 + 2
RSpec: expect(2 + 2).to eq(4)
D
Minitest: it 'adds numbers' do
  expect(2 + 2).to eq(4)
end
RSpec: test 'sum' do
  assert_equal 4, 2 + 2
end
Attempts:
2 left
💡 Hint
Remember Minitest uses assert methods, RSpec uses expect syntax.
component_behavior
intermediate
2:00remaining
Test Output Differences Between Minitest and RSpec
When running a failing test that expects 5 but gets 3, which output snippet correctly shows how Minitest and RSpec report the failure?
A
Minitest: Expected: 5
  Actual: 3
RSpec: expected: 5 got: 3
B
Minitest: Failure:
Expected: 5
  Actual: 3
RSpec: 
  1) Failure:
  expected: 5
  got: 3
C
Minitest: Error: expected 5 but got 3
RSpec: Failure/Error: expect(3).to eq(5)
D
Minitest: expected 5 got 3
RSpec: Failure: expected 5 but got 3
Attempts:
2 left
💡 Hint
Look for the detailed failure message format typical for each framework.
lifecycle
advanced
2:00remaining
Setup and Teardown Differences in Minitest and RSpec
Which code snippet correctly shows how to run setup code before each test in Minitest and RSpec?
A
Minitest: setup do
  @user = User.new
end
RSpec: before_all do
  @user = User.new
end
B
Minitest: before(:each) do
  @user = User.new
end
RSpec: def setup
  @user = User.new
end
C
Minitest: def before_each
  @user = User.new
end
RSpec: setup do
  @user = User.new
end
D
Minitest: def setup
  @user = User.new
end
RSpec: before(:each) do
  @user = User.new
end
Attempts:
2 left
💡 Hint
Minitest uses method overrides, RSpec uses hooks.
📝 Syntax
advanced
2:00remaining
Correct Syntax for Skipping Tests in Minitest and RSpec
Which option correctly shows how to skip a test in Minitest and RSpec?
A
Minitest: def test_example
  skip "Not implemented"
end
RSpec: it 'does something', skip: true do
  expect(true).to eq(true)
end
B
Minitest: def test_example
  pending "Not implemented"
end
RSpec: it 'does something' do
  skip "Not implemented"
end
C
Minitest: def test_example
  skip_test "Not implemented"
end
RSpec: it 'does something', pending: true do
  expect(true).to eq(true)
end
D
Minitest: def test_example
  ignore "Not implemented"
end
RSpec: it 'does something', ignore: true do
  expect(true).to eq(true)
end
Attempts:
2 left
💡 Hint
Minitest uses skip method, RSpec uses metadata flags.
🔧 Debug
expert
3:00remaining
Identifying the Cause of a Test Failure in Minitest vs RSpec
Given the following test code, which option correctly identifies the cause of failure when running in Minitest and RSpec respectively? Minitest test: ```ruby def test_greeting assert_equal 'Hello, Bob!', greet('Alice') end ``` RSpec test: ```ruby it 'greets Bob' do expect(greet('Alice')).to eq('Hello, Bob!') end ``` Assuming the greet method returns "Hello, Alice!", what is the cause of failure?
ABoth fail because the expected greeting is for 'Bob' but the method returns greeting for 'Alice'.
BMinitest passes but RSpec fails because of mismatched strings.
CMinitest fails due to syntax error; RSpec fails because of wrong expectation.
DBoth pass because the greet method returns a string.
Attempts:
2 left
💡 Hint
Check the expected vs actual values carefully.