Only require generator_spec when needed

`generator_spec` has a dependency on Railties, which defines the Rails module, apparently without defining the `.env` method that is needed when testing on Rails 4.1.

See https://github.com/rails/rails/blob/v4.1.0/activerecord/lib/active_record/connection_handling.rb#L3

This will hopefully fix the failing specs in #1364.