2

I installed the current RSpec 2 Beta under Rails 3 RC as mentioned on the GitHub page (and several blogs). Everything works fine, but I am not able to turn off specific generators like advised on some blogs.

Here is what I do in ./config/application.rb:

config.generators do |g|
  g.test_framework :rspec, :fixtures => false, :views => false
end

But when doing a "rails g scaffold Model name:string" those view specs are still generated. What's wrong with my setup?

tshepang
  • 12,111
  • 21
  • 91
  • 136
medihack
  • 16,045
  • 21
  • 90
  • 134

2 Answers2

7

You'll want to pass the :view_specs => false option too. I don't know why this is different between the controller generator (where :views => false has effect) and scaffold. I'll ask David.

Ryan Bigg
  • 106,965
  • 23
  • 235
  • 261
  • Thanks for taking care of this. "view_specs => false" works. Is that somewhere documented? With trial and error I also found out that there is a "routing_specs => false". But there is no "model_specs => false" ... I didn't figure that out. – medihack Aug 20 '10 at 21:48
  • @Zardos: no problem! I just looked in the code for the generator. Whilst it's helpful if you know where to look it would be *really* helpful if this was documented. – Ryan Bigg Aug 20 '10 at 21:52
  • @RyanBigg thanks for the :view_specs tip, I ran into same issue. – Gabor Garami Jan 15 '12 at 16:56
2

You can not stop generation of model spec, that is necessary and if you hope into the source code for rspec generator model/model_generator.rb you'll find there is no class_option :model_spec ....

Options allowd are give below, except webrat that can also be added or

config.generators do |g| 
  g.test_framework :rspec, :view_specs => false, :controller_specs => false, 
    :helper_specs => false, :routing_specs => false, :fixture => true,
    :fixture_replacement => "factory_girl"
end 
rubyonrails3
  • 259
  • 2
  • 6