Creating generator tests

I want to go in and improve the default scaffold (ex
resource_scaffold) a bit and noticed the lack of tests for generators.

So I thought I'd give people a heads up that I'm working on creating
initially tests for the scaffold generator as well as test helpers to
make it simpler to test generators in the future. I'll probably go
through and create tests for the built in generators as well
eventually.

I have a question about layout. I'm currently placing the scaffold
tests in:

railties/test/rails_scaffold_generator_test.rb

Does that make sense naming wise? So afterwards there could be:

railties/test/rails_model_generator_test.rb
etc.

I've also created the test helpers in

railties/test/generator_test_helpers.rb

Does that follow convension or should I rather put them somewhere
else, to make it easier for say plugin developers to use them?

Finally as part of my testing I build up a very basic rails directory
structure under railties/test/fixtures/tmp and then delete it again in
the teardown. I have seen similar things done in the tests from
various plugins and it works, can anyone see any issues with that?

Pelle

I want to go in and improve the default scaffold (ex
resource_scaffold) a bit and noticed the lack of tests for generators.

So I thought I'd give people a heads up that I'm working on creating
initially tests for the scaffold generator as well as test helpers to
make it simpler to test generators in the future. I'll probably go
through and create tests for the built in generators as well
eventually.

Sounds great, Pelle.

I have a question about layout. I'm currently placing the scaffold
tests in:

railties/test/rails_scaffold_generator_test.rb

Does that make sense naming wise? So afterwards there could be:

railties/test/rails_model_generator_test.rb
etc.

I've also created the test helpers in

railties/test/generator_test_helpers.rb

Does that follow convension or should I rather put them somewhere
else, to make it easier for say plugin developers to use them?

how about a test subdirectory, like railties/test/generators/*

Finally as part of my testing I build up a very basic rails directory
structure under railties/test/fixtures/tmp and then delete it again in
the teardown. I have seen similar things done in the tests from
various plugins and it works, can anyone see any issues with that?

Nope. All good.

jeremy

Great

OK. I've uploaded my patch with the scaffold generator tests at:

http://dev.rubyonrails.org/ticket/8443

It also includes a generator_test_helper module, which has lots of
helpful assertions, which could be used for testing most kinds of
generators.

Regards
Pelle