

Rails unit-testing best practices - mike_masi
https://blog.rainforestqa.com/2014-07-28-optimal-rails-unit-testing-toolset/

======
_raul
I've seen many Rails beginners feeling overwhelmed by the extensive amount of
tools they can use to start testing their apps. This is a nice post for them,
as it gives a good overview of some of those tools and how they fit together.

I would have written a different title though, because as the last paragraph
indicates, the post recommends some tools but not best practices (which at
this basic level would be things like: minimize the interaction with the
database and external systems, extract duplicated test code to helpers, label
your tests with descriptive names, etc).

~~~
jipiboily
Glad you liked it.

Yeah, good point on the title! ;)

------
omnikron
Nice summary of one of the many different testing philosophies (this one
happens to be very close to my own).

As an alternative, where you currently have:

    
    
      it { expect(client.active?).to be_false }
    

It might be even more idiomatic to write:

    
    
      subject { client }
      it { should_not be_active }
      # etc.
    

...beautiful!

~~~
omnikron
Or even better, simply replace

    
    
      let(:client) { create(:client, :inactive) }
    

with

    
    
      subject { create(:client, :inactive) }
    

and then carry on as above.

Rspec's syntax is great.

------
jipiboily
I am the author of that post, feel free to ask any question or give feedback
:)

