←back to thread

194 points onnnon | 1 comments | | HN request time: 0s | source
Show context
caseyohara ◴[] No.44502713[source]
> I know, we can vibe away all the boilerplate required for Rails apps. But how much fun is that? How much do you enjoy setting up RSpec, again, in your new Rails app? How tired are you of changing the “front end solution” every few years? And aren’t you just tired of debating where your business logic goes or if it’s OK to use HTTP DELETE (tunneled over a _method param in a POST) to archive a widget?

For your personal hobby project, go nuts. Break all the rules and cowboy all your own conventions.

But for business applications, the conventions Rails enforces at least make codebases somewhat familiar if you've seen a Rails codebase before.

At a certain codebase size, boilerplate is almost unavoidable. Unpleasant, but necessary. Personally, I'd rather have some conventions, rules, and guardrails for where the boilerplate lives rather than trying to navigate your homegrown pile of code. Good luck maintaining that spaghetti when you've got multiple developers.

It's not clear how this new web framework avoids boilerplate anyway, so I don't see how this is an improvement over Rails. Presumably you'll still need to set up lots of stuff yourself, like RSpec. If the framework sets all of that stuff up for you in a conventional way, then you're just back to square one as soon as you need to fight against the framework's conventions.

replies(3): >>44502836 #>>44503031 #>>44505426 #
davetron5000 ◴[] No.44503031[source]
Author here. The framework does require setting stuff up. RSpec is not one of those things. It's the testing library you will use if you use this framework. I didn't create a lot of flexibility in the framework. For example, if you don't like RSpec, you will not like this framework :)

You may want to examine the docs more closely. There are plenty of conventions and very few that can be circumvented.

But day one of a new framework is not going to compete with Rails. Sorry!

replies(1): >>44503226 #
stouset ◴[] No.44503226[source]
To be honest, I love this framework (so far from what I've seen) but I do hate the choice of RSpec. I say this as someone who used RSpec for like a decade after it was first released. I "get" it. I have contributed code to it.

Minitest (which is bundled with Ruby these days) is Good Enough™. It doesn't require you to learn a new DSL. Everything is just Plain Old Ruby. The use of RSpec these days—IMO—is just cargo-culting forward what was the right decision from 10+ years ago. Having an pseudo-English style interface for testing isn't worth having the additional dependencies nor the mental overhead of needing to know how the RSpec syntax is actually mapped into Ruby concepts.

I'm not asking you to change it, you're welcome to have a different opinion than mine. But I am curious if you have strong reasons for requiring it. Particularly because MiniTest seems to be well-aligned with the rest of your design philosophies, unlike RSpec.

replies(1): >>44503274 #
davetron5000 ◴[] No.44503274[source]
I thought hard about this decision. Every time I use MiniTest, I end up wanting a bit more that RSpec has and then switching to it. I also have been surprised over the years that the `expect(x).to eq(y)` seems to be relatively intuitive to people, despite the fact that it doesn't seem like it ought to be.
replies(1): >>44503314 #
stouset ◴[] No.44503314[source]
Do you mind elaborating on what more you end up wishing you had?

Most of the additional features RSpec adds seem worthwhile but just end up being more complicated/confusing in the end, in my experience. Shared contexts/examples, for example. Others like let blocks should… just be methods.

I will say the change in… I think it was RSpec 3(?) to the expect(x) syntax was a hugely positive change, particularly in not having to monkeypatch the world.

replies(2): >>44503349 #>>44503911 #
davetron5000 ◴[] No.44503349[source]
The biggest thing is the mocking system. MiniTest's feels so difficult to use.

I also like creating custom matchers vs. creating my own assert_* methods.

I would agree that many features of RSpec are, honestly, bad: shared examples, shared contexts, etc. Excessive use of let! and let, plus the predicate matchers are all just really confusing to me.

I actually thought about patching the RSpec gem to remove the features I didn't like :) Might still consider it heh

replies(2): >>44503530 #>>44507122 #
stouset ◴[] No.44503530[source]
The mocking thing actually touches on another point of frustration for me. I think the design of Rails ends up causing people to reach for mocking way too often in order to test things. At a glance I think Brut should avoid a lot of this by having things just be plain old Ruby objects.

I have dealt with countless Rails projects where testing things conventionally was difficult or impossible so mocks/stubs had to be used everywhere (controllers are the worst offenders here). When you start digging in to what's actually being tested, you find that the tests express little more than "this method is written the way it's currently written" rather than actually testing behavior.

Good tests should do three important things: catch bugs early in development, prevent regressions, and allow refactoring. Overly-mocked tests not only end up doing none of these but often actively work against these goals. They can't catch bugs because they reaffirm the current implementation rather than testing behavior. They can't catch regressions because any change to the code necessitates a change to the test. And they actively inhibit refactoring for both of those reasons.

All that is to say that maybe having a less-convenient mocking system is maybe a good thing :)

Also, since you're here, I want to say it also looks like your design encourages avoiding one of my other huge issues with Rails. I hate that ActiveRecord conflates the ORM layer with domain logic. This causes an antipattern where consumers of records (usually controller methods) pierce all the way down into the database layer by using AR methods and attributes directly. While convenient, this makes doing database-layer changes excruciating since your table layout is implicitly depended upon by pieces everywhere throughout the stack.

Better is to do what it looks like you suggest here: there should be an ORM layer that just exposes the database structure, and then you should layer domain objects on top of that which expose higher-level methods for interacting with persisted objects. If you change the database, you only need to change the mid-level layer. None of its consumers need to care that the underlying table layout changed.

From what I can tell so far I am very excited about Brut.

replies(2): >>44503590 #>>44504991 #
hotpocket777 ◴[] No.44504991[source]
_in your opinion_

My opinion is, _my unit tests_ are to protect my code against unwanted changes. To that end, unit tests test a single unit. And everything is mocked. If I have to rewrite a method, usually I rewrite all of its unit tests. Which is fine. They’re easy to write or rewrite.

Fully mocked unit tests are then supplemented with fewer “full stack” tests higher up the pyramid.

replies(2): >>44505051 #>>44510309 #
stouset ◴[] No.44505051[source]
> My opinion is, _my unit tests_ are to protect my code against unwanted changes.

This is just about the most bizarre take on unit testing I've seen in my 25-year career.

> If I have to rewrite a method, usually I rewrite all of its unit tests.

If you have to rewrite your tests every time you rewrite a method, you are entirely defeating the point of testing. What value you get from tests that only assert that the current implementation is equal to the current implementation?

replies(2): >>44505282 #>>44505495 #
1. hotpocket777 ◴[] No.44505282[source]
> This is just about the most bizarre take on unit testing I've seen in my 25-year career.

Lol ok

> you are entirely defeating the point of testing

We will disagree here

> only assert that the current implementation is equal to the current implementation

I didn’t state that I do this