"rails plugin new my_plugin --dummy-path custom/path/name" breaks #6251

Closed
EricR opened this Issue May 10, 2012 · 1 comment

Projects

None yet

2 participants

EricR commented May 10, 2012

While using Rails 3.2.3 and generating a rails plugin, specifying a dummy app that isn't named "dummy" throws an exception:

project/ $ rails plugin new my_plugin --dummy-path spec/my_plugin -T --skip-bundle

(generator output omitted...)
/usr/local/rvm/gems/ruby-1.9.2-p290@global/gems/railties-3.2.3/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb:285:in `application_definition': bad value for range (ArgumentError)
  from /usr/local/rvm/gems/ruby-1.9.2-p290@global/gems/railties-3.2.3/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb:229:in `block in create_dummy_app'
  from /usr/local/rvm/gems/ruby-1.9.2-p290@global/gems/thor-0.14.6/lib/thor/shell/basic.rb:18:in `mute'
  from /usr/local/rvm/gems/ruby-1.9.2-p290@global/gems/railties-3.2.3/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb:314:in `mute'
  from /usr/local/rvm/gems/ruby-1.9.2-p290@global/gems/railties-3.2.3/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb:227:in `create_dummy_app'
  from /usr/local/rvm/gems/ruby-1.9.2-p290@global/gems/railties-3.2.3/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb:208:in `create_test_dummy_files'
  from /usr/local/rvm/gems/ruby-1.9.2-p290@global/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
  from /usr/local/rvm/gems/ruby-1.9.2-p290@global/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
  from /usr/local/rvm/gems/ruby-1.9.2-p290@global/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `block in invoke_all'
  from /usr/local/rvm/gems/ruby-1.9.2-p290@global/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `each'
  from /usr/local/rvm/gems/ruby-1.9.2-p290@global/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `map'
  from /usr/local/rvm/gems/ruby-1.9.2-p290@global/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `invoke_all'
  from /usr/local/rvm/gems/ruby-1.9.2-p290@global/gems/thor-0.14.6/lib/thor/group.rb:226:in `dispatch'
  from /usr/local/rvm/gems/ruby-1.9.2-p290@global/gems/thor-0.14.6/lib/thor/base.rb:389:in `start'
  from /usr/local/rvm/gems/ruby-1.9.2-p290@global/gems/railties-3.2.3/lib/rails/commands/plugin_new.rb:11:in `<top (required)>'
  from /usr/local/rvm/gems/ruby-1.9.2-p290@global/gems/railties-3.2.3/lib/rails/commands.rb:22:in `require'
  from /usr/local/rvm/gems/ruby-1.9.2-p290@global/gems/railties-3.2.3/lib/rails/commands.rb:22:in `<top (required)>'
  from script/rails:6:in `require'
  from script/rails:6:in `<main>'

It seems that the name "Dummy" is hardcoded into the generator, on line 285 of railties-3.2.3/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb:

unless options[:pretend] || !File.exists?(dummy_application_path)
  contents = File.read(dummy_application_path)
  contents[(contents.index("module Dummy"))..-1]
end
@drogus drogus added a commit that referenced this issue May 11, 2012
@drogus drogus Failing test for #6251 b14d1cd
@drogus drogus added a commit that referenced this issue May 11, 2012
@dabit @drogus dabit + drogus Fixes issue #6251
Plugin generator crashes when using the --dummy-path option

Code was assuming the application name in `config/application.rb`
was module Dummy.
0d48b12
@drogus drogus closed this May 11, 2012
Member
drogus commented May 11, 2012

@dabit thanks for the patch, I just added failing test for it

@senny senny added a commit to senny/rails that referenced this issue Nov 15, 2012
@dabit @senny dabit + senny Fixes issue #6251
Plugin generator crashes when using the --dummy-path option

Code was assuming the application name in `config/application.rb`
was module Dummy.
00fbee5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment