Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Auto merge of #6304 - deivid-rodriguez:fix/new_gem_generation_crash, …
Browse files Browse the repository at this point in the history
…r=colby-swandale

Fix `bundle gem` generating unparsable ruby

### What was the end-user problem that led to this PR?

The problem was that the main file in a gem generated by `bundle gem` can't be inspected via `rubocop`.

### What was your diagnosis of the problem?

My diagnosis was `bundler` was generating unparsable ruby in the generated gem.

### What is your fix for the problem, implemented in this PR?

My fix was to change the offending template to generate valid ruby code.

### Why did you choose this fix out of the possible options?

I chose this fix because it's the only one, really.

(cherry picked from commit 3d82585)
  • Loading branch information
bundlerbot authored and colby-swandale committed Sep 20, 2018
1 parent ebdcabf commit e69411c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/bundler/templates/newgem/lib/newgem.rb.tt
Expand Up @@ -6,7 +6,7 @@ require "<%= config[:namespaced_path] %>/<%= config[:underscored_name] %>"
<%- config[:constant_array].each_with_index do |c, i| -%>
<%= " " * i %>module <%= c %>
<%- end -%>
<%= " " * config[:constant_array].size %>class Error < StandardError; end %>
<%= " " * config[:constant_array].size %>class Error < StandardError; end
<%= " " * config[:constant_array].size %># Your code goes here...
<%- (config[:constant_array].size-1).downto(0) do |i| -%>
<%= " " * i %>end
Expand Down
2 changes: 1 addition & 1 deletion spec/commands/newgem_spec.rb
Expand Up @@ -311,7 +311,7 @@ def create_temporary_dir(dir)
end

it "creates a base error class" do
expect(bundled_app("test_gem/lib/test_gem.rb").read).to include("class Error < StandardError")
expect(bundled_app("test_gem/lib/test_gem.rb").read).to match(/class Error < StandardError; end$/)
end

it "runs rake without problems" do
Expand Down

0 comments on commit e69411c

Please sign in to comment.