Ask A Question

Notifications

You’re not receiving notifications from this thread.

RSpec w/capybara vs Mini Test

Drilon Buzuku asked in Testing

Hey guys,

what are your thoughts on RSpec vs Mini Test. Which one do you use and why?

Cheers,

Drilon

Reply

I rarely use TDD/BDD when building an app, but when I do I use RSpec/Capybara/FactoryGirl/Selenium and maybe a few others I can't think of off the top of my head. I've never used Mini Test.

Strictly following TDD/BDD takes all the fun out of developing for me.

This is a good talk on TDD
https://youtu.be/z9quxZsLcfo

Reply

I'm generally pretty torn on the two. Rspec is great because there are so many examples out there, but I really really dislike the DSL it adds because it obfuscates a lot. Minitest is great because it's just plain Ruby where you can refactor all your work like you regularly would.

I guess generally that leads me to suggest Rspec if you're new and Minitest if you're good at Ruby.

@Nick, I feel the same way about TDD. It doesn't add much for me which is why I generally just add tests as I need rather than doing full blown TDD.

Reply

On the other hand, I prefer Minitest because it doesn't have a different DSL to learn while learning ruby/rails. It can be a lot to keep up with I found if you try and pick up RSpec while learning ruby. (though the one con of not going Rspec is it seems like the large majority of tutorials out there use Rspec)

As for the TDD stuff, I usually take the approach that testing is super important but I generally won't write tests first. I usually write my tests after I'm done with the feature but before I refactor it.

I usually use minitest and capybara for feature tests.

Reply

My .02c

I don't TDD. I've tried it and find it too constraining. As far as testing I really don't focus on 100% test coverage in production apps. I tend to focus on unit, integration, and system testing on the important parts that could easily break. You could say that testing is not my favorite thing.

As far as frameworks I'm agnostic. I work with both Minitest and Rspec. Like Chris and the others have mentioned Rspec has a DSL that you have to learn which is good if you're just starting out with Ruby and don't feel very confident yet. Minitest is pure ruby so for myself I find it a bit more flexible for my workflow. But I'm stuck in a space where I have apps that use each one.

But if I could pick one framework and stick with it. Minitest.

Also do some searches on YouTube for minitest and Aaron Patterson. He's really good with it and has a lot of best practice lectures on it.

Reply

Can anybody recommend any good tutorials/books/videos with Mini Test that are meant for beginners to rails (and ruby)?
I personally prefer videos, but mini test seem to be such a rarity I'll take anything I can get.

Reply

@sweedledee there's not a lot of good examples out there! I did a lot of the Testing Rails series in Minitest which is a start. The Rails test suite is where I learned a good bit if you feel like digging through the repository.

I bought betterminitest.com to document common use cases and need to start putting that site together!

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,329+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

    © 2024 GoRails, LLC. All rights reserved.