GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
Generating a rails engine with rails plugin new <engine_name> -T --dummy-path=spec/dummy --mountable doesn't appear to properly generate the Rakefile.
rails plugin new <engine_name> -T --dummy-path=spec/dummy --mountable
Normally, generating a rails engine with testunit includes these two lines in the Rakefile:
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
If I simply pass -T, these two lines are not added to the Rakefile and the dummy application obviously isn't generated.
However, if I request that a dummy application is still generated without TestUnit, these two lines are not added to the engine Rakefile even though the dummy application is generated. Without these two lines, the output of rake -T is:
rake build # Build testplugin_notunit-0.0.1.gem into the pkg directory
rake clobber_rdoc # Remove RDoc HTML files
rake install # Build and install testplugin_notunit-0.0.1.gem into system gemsrake rdoc # Build RDoc HTML filesrake release # Create tag v0.0.1 and build and push testplugin_notunit 0.0.1.gem to Rubygems
rake rerdoc # Rebuild RDoc HTML files
Re-adding the above two lines to the engine Rakefile allows rake to access the rest of the rake targets that are missing. I'm not sure if this is intended behavior, but this seems like a bug to me. I requested a new engine with a dummy application and the Rakefile isn't properly configured for such a setup out of the box.
Do you use the :dummy_path option to generate the dummy app when you skip test unit?
Yes, the exact invokation that reproduces it is rails plugin new <engine_name> -T --dummy-path=spec/dummy --mountable
I'll look into it. I think it should be an easy fix and I'll report back when I made some progress.
The relevant code is https://github.com/rails/rails/blob/master/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile#L17-20
<% if full? && !options[:skip_active_record] && !options[:skip_test_unit] -%>
This was recently changed (commit: 5fa8728) and used to be:
<% if full? && !options[:skip_active_record] -%>
I can easily fix it so that it will also include the necessary lines when you add --dummy-path but there is always the full? condition. I noticed that you use --mountable and I'm not sure if the tasks should be added for mountable engines.
@steveklabnik do you know the desired behavior and why full? is being checked?
I do not.
@drogus a git blame revealed, that you are involved in the generator code. Could you clarify about the full? check and if the situation described is actually a bug or intended behavior.
@senny mountable is also "full" application: https://github.com/rails/rails/blob/master/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb#L274-276, so I think it's safe to do that change.
Honestly, when I think about this full vs mountable, I'm not even sure which one should include which parts. From what I remember, mountable was supposed to create an engine with routes that can be mounted and full should additionally add app, assets etc. The problem is, when I look at the code it does not look like it's the case.
@senny so, to sum up, I will happily accept a patch that fixes the case where you want dummy app, but no test unit, but I will need to review history to see what's going on there.
@drogus thanks for the heads up. I'll submit the patch laters.
`plugin new` adds dummy app tasks when necessary.
The `plugin new` generator always adds the dummy app rake tasks,
when a dummy app was created.