Display actual content in failure message #4

wants to merge 1 commit into


None yet
3 participants

When doing BDD I find it very useful to see the actual content that failed to match along with the matcher itself. Did a basic implementation pretty much following the "Expected:" compared to "Actual:" pattern in the must_equal matcher.

How do you like it? Any suggestions for further improving it?

I was thinking of doing a pretty print for larger documents, but skipped it for the sake of simplicity.

@ghost ghost assigned ordinaryzelig Jun 5, 2012


ordinaryzelig commented Jun 5, 2012

Actually, I'm leaning towards ending this gem in favor of @wojtekmach's minitest-capybara. It uses @zenspider's minitest-matcher, which is meant to bridge the gap between MiniTest and matchers such as Capybara's RSpec matchers. There's a lot of benefits to that including getting Capybara's default failure messages for free.

Any thoughts?

@codebeige codebeige closed this Jun 6, 2012

I am currently trying to set up some very lean Rails testing with MiniTest::Spec without all the magic known from Rspec. I want to find out, what I miss most and how all these things actually work under the hood. minitest-matcher is adding exactly that kind of complexity that I am currently trying to avoid.

When it comes to collaborative projects, me and my team will probably use something like 'minitest-capybara`at the end. So if you do not plan to keep this project alive, feel free to simply ignore my pull request.

@codebeige maybe I should have pointed that out, but one of main reasons I created minitest-matchers is not because I like matchers. It was compatibility to existing libraries (valid_attribute was the first one), many are unfortunetly RSpec only. I even tried to make it a little more minitest-like and you can write must_have_content instead must have_content, there's a very subtle difference. Anyway, use the project and feel free to report any issues you encounter.

@wojtekmach thank you for comment.

I like minitest-matcher and it is really good to have sort of a compatibility layer to existing libraries through it. I am also a big fan of Rspec and all the evolution it brought to testing/specing in general.

On the other hand I want to have a testing library that is as lean and fast as possible. I want to fully understand and control what is going on. For me MiniTestdoes a great job on that. I don't want to ruin that by bloating it unnecessarily.


ordinaryzelig commented Jun 6, 2012

I was in the exact same place as you when I wrote this gem. I wanted to stay as far away from RSpec as possible. However, after looking through the internals of minitest and capybara, I don't feel using minitest-capybara is a complete "sell-out" for lack of better words. It's more of a use of duck-typing, if you will. And if you can see it like that, minitest-capybara is a more snug fit for accomplishing the same thing. You're not necessarily making anything more bloated.

If you want, you can just use minitest-matchers and bridge the gap between minitest and capybara yourself. It's really easy. Maybe 10 lines of code. There's even a mention of it in minitest-matcher's documentation. Plus you'll get more familiar with how things work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment