Running specs without Rails

For most of the Rails work I do, I prefer to run specs without Rails as much as possible. The core of the system is usually in PORO’s so there is no need to wait for Rails environment to load. The idea is picked up from the web, of curse, but with a little twist. In all the PORO’s I reference the spec_helper_without_rails.rb, with the below configuration. Note that some part were left out, because they are not relevant to this topic, but the important part is that Rails is not referenced at all.

Now, to run those specs, one recommendation is to run it with RSpec tags. What bothered me is that Rails environment is loaded after all, because RSpec seems to load all specs before filtering them out. This resulted in PORO specs being executed / filtered out correctly, but the load time was slow as before. The trick eventually is to run RSpec only for those specs that use the above helper without Rails. And for that I created a shell/bash script that does just that:

Now, the PORO specs are fast again (~3000 per second on my machine) and life is beautiful again too 🙂

Advertisements
Tagged , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: