This project is archived and is in readonly mode.
Rails 3.0 generator inconsistency
Reported by manu | October 12th, 2010 @ 11:46 PM | in 3.x
I am trying create an app that has no DB backend.
I generated the app using
rails new myapp -T -O
The problem is when I create a controller
using
rails generate controller mycontroller
I see some test unit file being generated..
test/functional/home_controller_test.rb
test/unit/helpers/home_helper_test.rb
and therefore rake test causes the following error
./test/functional/home_controller_test.rb:1:in require':
no such file to load -- test_helper (LoadError)
from ./test/functional/home_controller_test.rb:1
from /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `load'
from /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
from /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `each'
from /usr/lib/ruby/gems/1.8/ge
Is this the expected behavior? I believe if I skip test unit, I should never have any test unit file created, right?
Comments and changes to this ticket
-
Rob Zolkos October 13th, 2010 @ 05:34 AM
I can confirm this behaviour.
I agree that if a rails app is created with the -T option then the following should be injected into application.rb
config.generators do |g| g.test_framework nil end
Then subsequent generators won't generate any test files.
-
Ryan Bigg October 13th, 2010 @ 05:44 AM
- State changed from new to incomplete
- Importance changed from to Low
Please submit a patch to fix this issue, along with tests.
-
manu October 13th, 2010 @ 04:38 PM
Why is this marked as incomplete? What else do you need? I can also show you how cucumber rails totally breaks in this case.
-
Aditya Sanghi October 13th, 2010 @ 06:01 PM
The ticket is marked incomplete while it is awaiting patches to fix the problem. Feel free to submit a patch. If you dont want to or cant for some reason, let me know. Someone else might pick up the challenge.
-
Rob Zolkos October 14th, 2010 @ 05:28 AM
I'll have a swing at writing a patch. Before I do, is there any existing design decision that was made that causes rails generators to create test files if the rails app was created with -T, or is it a bug that needs fixing?
-
Rob Zolkos October 14th, 2010 @ 02:20 PM
Attached is patch and tests.
if rails app is created with -T or --skip-test-unit then the application.rb will contain
config.generators do |g|
g.test_framework nil endwhich will then mean that any future generators will not generate any test files.
-
Elad Meidar October 14th, 2010 @ 03:33 PM
Verified and Patch is working on stable,
Just one thing: the patch adds aconfig.generators
block, isn't there anything else that adds this block already and might cause more than 1 to appear in the final output? -
Rob Zolkos October 15th, 2010 @ 12:30 PM
I searched through the source today and couldn't find anything else or anywhere else that adds this block into application.rb
-
Aditya Sanghi October 19th, 2010 @ 12:26 PM
- State changed from incomplete to verified
- Milestone set to 3.x
- Assigned user set to José Valim
-
José Valim October 19th, 2010 @ 12:41 PM
It looks good, I will apply it during the next weeks. Anyone in mood for supplying a similar patch to ActiveRecord? If so, you can use add "config.generators.orm false" to config/application.rb instead of giving a block.
Similarly, the previous patch could be using "config.generators.test_framework false", but I will handle that.
-
Aditya Sanghi October 19th, 2010 @ 01:00 PM
- Tag set to appgenerator, patch, railties
Adding patch to add
config.generators.orm = false
when skip active_record is given as per José's suggestion above. -
Rob Zolkos October 19th, 2010 @ 02:18 PM
And here is patch to add config.generators.test_framework = false when skip_test_unit is given.
That should save you some precious time José :)
-
Repository November 11th, 2010 @ 04:36 PM
- State changed from verified to resolved
(from [bafa1533f414a3d3c02528b774e5cf28e85774b5]) skip testing framework if app created with --skip-test-unit [#5796 state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
https://github.com/rails/rails/commit/bafa1533f414a3d3c02528b774e5c... -
Aditya Sanghi November 12th, 2010 @ 06:54 AM
José,
There is another patch here that needs to be applied. As per your suggestion above, I added a patch to set config.generators to false if --skip-activerecord option has been provided.
Do you want me to create another ticket for it?
Cheers,
Aditya -
José Valim November 12th, 2010 @ 06:56 AM
- State changed from resolved to open
There is no need. I am reopening this one, thanks!
-
rails March 23rd, 2011 @ 12:00 AM
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
rails March 23rd, 2011 @ 12:00 AM
- State changed from open to stale
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 5796 Rails 3.0 generator inconsistency (from [bafa1533f414a3d3c02528b774e5cf28e85774b5]) skip te...