This project is archived and is in readonly mode.

#4534 ✓resolved
Adrian Sanchez

Bundler deprecated options in Gemfile with application template using method "gem"

Reported by Adrian Sanchez | May 5th, 2010 @ 06:59 AM

Deprecated gem options in application templates

Bunlder deprecated options

Update deprecated options in rails application template when method "gem" is called and options are:

  • :env
  • :only
  • :lib
  • :require_as

For example:

Given I have a rails application template "my_template.rb" with:
gem 'cucumber', :env => :test, :version => '>=0.7.2'
gem 'cucumber-rails', :only => :test

When I create a rails app with:
rails my_app --template=my_template.rb

Then "my_app/Gemfile" file should contain:
gem "cucumber", ">=0.7.2", :group => :test
gem "cucumber-rails", :group => :test

And I should get a warning message something like:
DEPRECATION WARNING: :env option in gem is deprecated, use :group instead.
DEPRECATION WARNING: :only option in gem is deprecated, use :group instead.


Updated Test file (rails/railties/test/generators/actions_test.rb):

def test_gem_with_env_should_include_all_dependencies_in_gemfile
  run_generator

  assert_deprecated do
    action :gem, 'rspec', :env => %w(development test)
  end

  assert_deprecated do
    action :gem, 'rspec-rails', :only => %w(development test)      
  end

  assert_file 'Gemfile', /gem "rspec", :group => \["development", "test"\]/
  assert_file 'Gemfile', /gem "rspec-rails", :group => \["development", "test"\]/
end

def test_gem_with_options_should_include_all_options_in_gemfile
  run_generator

  assert_deprecated do
    action :gem, 'mislav-will-paginate', :lib => 'will-paginate', :source => 'http://gems.github.com'
  end

  assert_deprecated do
    action :gem, 'thoughtbot-factory_girl', :require_as => 'factory_girl', :source => 'http://gems.github.com'
  end    

  assert_file 'Gemfile', /gem "mislav\-will\-paginate", :require => "will\-paginate"/
  assert_file 'Gemfile', /source "http:\/\/gems\.github\.com"/
  assert_file 'Gemfile', /gem "thoughtbot-factory_girl", :require => "factory_girl"/
end

Versions

rails (3.0.0.beta3)
railties (3.0.0.beta3)
bundler (0.9.25)

Thank you.

Comments and changes to this ticket

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