Hanami: Change default testing framework to RSpec

Created on 21 Oct 2017  路  7Comments  路  Source: hanami/hanami

Right now minitest is our default testing framework. After discussing it with @jodosha, we think we should use rspec by default.

If possible, we'd also like to extract hanami-rspec and hanami-minitest gems from this repository (which we would maintain). These would be responsible for generating the test files. This would leverage not-yet-existing Hanami::CLI features of before and after hooks.

This will likely make our new project creation a little more complicated:hanami-rspec by default, or hanami-minitest would be added to the default Gemfile, then we'll have to run bundle install inside the folder in order to get download those gems (since they won't be hard dependencies of hanami) and create the appropriate files.

This is proposed for v1.2.0, not v1.1.0, which is currently in release candidate.

discussion

Most helpful comment

@seanfcarroll I agree with you regarding the focus on one framework.

We started having Minitest as default testing framework because it's lightweight, but I never used it for large web app code bases. And still when I start a new project, RSpec is my choice.

The goal here is to bring as much as possible value according to our experience. RSpec for me is superior to Minitest for web apps.

All 7 comments

I'm a new user of Minitest and I really lack the feature to run a database setup (or any command) before a group of specs in single describe, I like this change :)

In the interest of discussion it might be useful to outline the conversation(s) you guys had and what arguments led to favoring Rspec over Minitest.

Also I think many/most people doing web development in Ruby will be fine with the proposed new project creation. Potentially you could add a flag to run Bundler automatically at the end, similar to what Padrino has:

Options | Default | Aliases | Description
-- | -- | -- | --
bundle | false | -b | execute bundler dependencies installation

@citizen428 I like your proposal, I'm going to open and issue for that.

I've worked with both RSpec and Minitest, and while RSpec is the defacto standard for many Rails projects, except Rails itself :-) , Minitest does have a couple of basic advantages.

1) The source code for Minitest is surprisingly small, and readable.
2) Minitest has a lot less magic, and especially if using the class-based non-DSL based approach. These tests are a lot more readable although also more wordy.

That being said, RSpec has a lot of batteries included which leads to increased developer productivity, once you have mastered the DSL. I am not really qualified to talk about Hanami as I am yet to write an app with it, but I have followed the project and I really like the fully OO / less magic approach.

I'm not looking to start a flame war or anything here ... just observing that Minitest can have very simple OO approach, which seems to be an advantage of Hanami.

This is an interesting comparison on the two frameworks.

I'd like to see Hanami become a well-used framework, and will likely convert one of my Rails apps into it when I have time. I am also wondering what a Crystal-based Hanami would look like.

Just to add another thought - whatever is decided, I think it is best to focus on a single testing framework as standard. The situation in Rails where the community is split is a bit counter-productive, especially for new devs who are looking for documents. This is different than a database or even ORM choice, as these are radically different. RSpec and Minitest basically do the same thing, with some differences in DSL and conventions.

The most important thing is that tests are code and should be easily readable months and years later.

Just my humble opinion.

@seanfcarroll I agree with you regarding the focus on one framework.

We started having Minitest as default testing framework because it's lightweight, but I never used it for large web app code bases. And still when I start a new project, RSpec is my choice.

The goal here is to bring as much as possible value according to our experience. RSpec for me is superior to Minitest for web apps.

Implemented by #928

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gmanley picture gmanley  路  6Comments

mkarganov picture mkarganov  路  3Comments

hedselu picture hedselu  路  5Comments

duykhoa picture duykhoa  路  6Comments

thelastinuit picture thelastinuit  路  4Comments