NoBrainerORM / nobrainer

Ruby ORM for RethinkDB
http://nobrainer.io/
Other
387 stars 49 forks source link

Rspec matchers for nobrainer ? #88

Closed zedtux closed 9 years ago

zedtux commented 10 years ago

I'm now using nobrainer and I was looking to test my models with RSpec but I can't figure out if a gem exists with all the RSpec matchers in order to test things like fields, associations and so on.

Do you know if this exists already ? If yes can you please point me to this resource ?

nviennot commented 10 years ago

This does not exist (at least not that I'm aware of).

Not that you've asked for it, but here's my opinion on these sort of tests: They do more harm than good. You should have integration tests. If removing one of these fields, or association does not break anything, then the field is probably useless anyway. These unit tests will not catch any regressions. However, they slow you down when you first write your code, and slow you down when you try to refactor things.

zedtux commented 9 years ago

I'm doing both, unit and integration testing. Unit testing was more about to avoid any accidental removal/update of a field for instance but I like your point of view ...

Let's close this issue ...

nviennot commented 9 years ago

If you accidentally remove a field, and none of your integration test break, then either 1) the field was not needed or 2) your integration tests are really bad

zedtux commented 9 years ago

You're definitely right!

zedtux commented 3 years ago

Since that discussion, I've a little bit changed my mind: While it is still true that Unit testing + Integration testing is kind of overlapping, it actually could help but on running the build.

What I mean by that is that running integration testing is a huge resources consumption and it takes a lot of time, while unit testing is blazing fast. Running Rspec before Cucumber (in my case) helps to ensure some basic checks (we are testing fields, indexes and validations, nothing more) preventing from running the build that will anyway fail due to that missing field (to keep that example).

For that reason I've made nobrainer-rspec in the case it could interest anyone. I heavily copy/past code from the mongoid-rspec gem, as nobrainer has a lot of similarities with mongoid.