diff options
author | The Bundler Bot <bot@bundler.io> | 2018-02-22 20:55:29 +0000 |
---|---|---|
committer | Colby Swandale <me@colby.fyi> | 2018-10-05 16:15:43 +1000 |
commit | 15dec01a1b38d3c22241d9ad9e8bf3a10e55d2a3 (patch) | |
tree | b05158119877ee7c1948020a940366620d1c4666 | |
parent | 2e4bae58271c20ece7ab8474145571532955dfac (diff) | |
download | bundler-15dec01a1b38d3c22241d9ad9e8bf3a10e55d2a3.tar.gz |
Auto merge of #6304 - deivid-rodriguez:fix/new_gem_generation_crash, 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 3d8258586b0fab8899d9a6f801d301e8db4d3ba6)
-rw-r--r-- | lib/bundler/templates/newgem/lib/newgem.rb.tt | 2 | ||||
-rw-r--r-- | spec/commands/newgem_spec.rb | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/lib/bundler/templates/newgem/lib/newgem.rb.tt b/lib/bundler/templates/newgem/lib/newgem.rb.tt index f441eab5f2..fae6337c3e 100644 --- a/lib/bundler/templates/newgem/lib/newgem.rb.tt +++ b/lib/bundler/templates/newgem/lib/newgem.rb.tt @@ -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 diff --git a/spec/commands/newgem_spec.rb b/spec/commands/newgem_spec.rb index d37d6c840c..4b5db87b00 100644 --- a/spec/commands/newgem_spec.rb +++ b/spec/commands/newgem_spec.rb @@ -311,7 +311,7 @@ RSpec.describe "bundle gem" do 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 |