4

Script/generate became very annoying since I started using rspec etc. I dont need unit test files and fixtures anymore, but script/generate makes them anyway.

Is it possible to set --skip-fixtures and --skip-test to be default system-wide (or at least project-wide)?

tshepang
  • 12,111
  • 21
  • 91
  • 136
Mantas
  • 5,691
  • 6
  • 27
  • 24

3 Answers3

6

You can edit your applications script/generate file to auto append options

#!/usr/bin/env ruby

ARGV << "--skip-fixture" if ["model"].include?(ARGV[0])

require File.dirname(__FILE__) + '/../config/boot'
require 'commands/generate'
Corban Brook
  • 21,270
  • 4
  • 28
  • 34
  • I like that you can do that and I always forget, that's why I make aliases instead - so I don't have to do it everywhere. – Brian Hogan May 19 '09 at 20:04
6

Well, for starters,

ruby script/generate rspec_model
ruby script/generate rspec_controller

At least that doesn't generate unit tests and it gets the specs there for me :)

But --skip-fixtures still has to get passed. I've just made my own aliases in .bash_profile

alias model='ruby script/generate rspec_model $1 --skip-fixture'

Then I can just do

model bar name:string active:boolean

and it all works :)

Brian Hogan
  • 3,033
  • 21
  • 18
1

I use minitest_rails as my testing framework, and you can set some defaults via the config/application.rb file.

config.generators do |g|
  g.test_framework :mini_test, :spec => true, :fixture => false
end

When you generate a model (and controller), it will now automatically skip the fixture. This example will also create the Unit Test using the minitest_spec format.

Jordan Brock
  • 141
  • 1
  • 5