What testing tools and methods did Corey Haines use at GoGaRuCo 2011?

In this video from GoGaRuCo 2011 , Corey Haines shows some methods for creating Rails test suites much faster. I would put it as follows:

  • Put as much code as possible outside the Rails application into other modules and classes
  • Test them separately, without the overhead of downloading Rails
  • Use them from a Rails application

However, there were a few things that I did not understand.

  • It alternates current tests with rspec and spn or spna (for example, at about 3:50). Is spn well-known tool?
  • In his tests for classes and non-Rails modules, he includes the tested module or class, but I do not see anything like spec_helper . How does he have rspec?
+7
source share
1 answer

Sorry for the confusion. spn and spna are the aliases that I have that add my no-rail code to the rspec boot path. They are nothing special except adding -I path_to_code on the command line.

These days I am adding something like this to my .rspec file:

 -I app/mercury_app 

Then I can do a simple require 'object_name' at the top of my specs.

As for not including spec_helper : it's true, I do not. When you execute your spec file with rspec <path_to_spec_file> , it is interpreted, so you do not need to explicitly specify rspec .

For my db specifications these days, I also created active_record_spec_helper , which requires active_record, establishes a connection to the test database and sets database_cleaner ; this allows me to simply require that my model be at the top of my spec file. This way I can check the AR code on db without loading the whole application.

The client I'm working on using these methods is interested in supporting some blog posts about this, so I hope they start appearing in mid-June.

+19
source

All Articles