shou2017.com
JP

Testing Multiple Classes with assert_select in Minitest

Thu Apr 18, 2019
Sat Aug 10, 2024

Using minitest’s integration test to test multiple classes like the following:

<div class="notification is-danger">
 <p>test</p>
</div>

At first, I wrote it like this, but the test didn’t pass:

  test "testing multiple classes" do
    assert_select 'div.notification is-danger'
  end

The correct approach is to use a do block:

test "testing multiple classes" do
  assert_select 'div.notification' do
    assert_select 'div.is-danger'
  end
end
See Also