Skip to main content

RSpec w/capybara vs Mini Test

Testing • Asked by Drilon Buzuku

Hey guys,

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

Cheers,

Drilon


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


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.


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.


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.


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.