Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3967856
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:46:14+00:00 2026-05-20T03:46:14+00:00

I wrote myself a custom matcher, which itself works fine. But the failure_message_for_should doesn’t

  • 0

I wrote myself a custom matcher, which itself works fine. But the failure_message_for_should doesn’t work, I still get the default failure message. The ...should_not works!

My matcher:

RSpec::Matchers.define :be_same_dom do |expected|
  match do |actual|
    assert_dom_equal(expected, actual)
  end

  failure_message_for_should do |actual|
    "Expected the same DOM as #{expected}, but got #{actual}"
  end

  failure_message_for_should_not do |actual|
    "Expected a different DOM than #{expected}"
  end
end

Failure messages:


Failure/Error: helper.link_to("Dictionary", dictionaries_path).should_not be_same_dom('<a href="/dictionaries">Dictionary</a>')
       Expected a different DOM than <a href="/dictionaries">Dictionary</a>

Failure/Error: helper.link_to("Dictionary", dictionaries_path).should be_same_dom('<a class="x" href="/dictionaries">Dictionary</a>')
     MiniTest::Assertion:
       <"<a class=\"x\" href=\"/dictionaries\">Dictionary</a>"> expected to be == to
       <"<a href=\"/dictionaries\">Dictionary</a>">..
       Expected block to return true value.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T03:46:14+00:00Added an answer on May 20, 2026 at 3:46 am

    I think what’s happening here is that the assert_dom_equal method raises an exception instead of returning false. RSpec catches the exception and returns the exception message instead of the matcher message.

    You should be able to catch this yourself:

    match do |actual|
      begin
        assert_dom_equal(expected, actual)
      rescue MiniTest::Assertion
        false
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom database class that I wrote myself, and I also have
I need to solve the following question which i can't get to work by
I wrote myself a little downloading application so that I could easily grab a
I could probably write this myself, but the specific way I'm trying to accomplish
I want to write a little app for myself which notifies me if there
I'm trying to practice myself with custom class loaders, and I've some questions. Is
I'm currently trying to test a strcat() function that I wrote myself. Instead of
I'm using pylons with sqlalchemy. I have several models, and found myself wrote such
So, I wrote a quick thread example for myself, using the ruby docs for
I write code in isolation, that is I work for myself. I need some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.