0

I'm writing a lot of request specs right now, and I'm spending a lot of time building up factories. It's pretty cumbersome to make a change to a factory, run the specs, and see if I forgot about any major dependencies in my data. Over and over and over...

It makes me want to set up some sort of sandboxed environment, where I could browse the site and refresh the database from my factories at will. Has anyone ever done this?

EDIT:

I'm running spork and rspec-guard to make this easier, but I still lose a lot of time.

A large part of that time is spent waiting for Capybara/FireFox to spin up. These are request specs, and quite often there are some JavaScript components that need to be exercised as well.

Wheeyls
  • 1,012
  • 1
  • 7
  • 14

1 Answers1

0

You might look at a couple of solutions first:

  • You can run specific test files rather than the whole suite with something like rspec spec/request/foo_spec.rb. You can run a specific test with the -e option, or by appending :lineno to the filename, where lineno is the line number the test starts on.
  • You can use something like guard-rspec, watchr, or autotest to automatically run tests when their associated files change.
  • Tools like spork and zeus can be used to preload the app environment so that test suite runs take less time to run. However, I don't think this will reload factories so they may not apply here.
  • See this answer for ways that you can improve Rails' boot time. This makes running the suite substantially less painful.
Community
  • 1
  • 1
Chris Heald
  • 61,439
  • 10
  • 123
  • 137
  • Hi Chris! I'm doing all 4 of your suggested bullet points; I isolate my individual specs, use spork to preload everything I can, and am running Ruby 2.0. I'm editing my question to provide a little more detail about my environment. – Wheeyls Jul 12 '13 at 20:07
  • Have you considered using poltergeist/phantomJS? You could spin up a phantomJS server when you boot your test suite (pre-sporking), which would then be used to run your acceptance tests in. This has the benefit of playing well with CI! – Chris Heald Jul 12 '13 at 20:43