File tree Expand file tree Collapse file tree
lib/generators/react_on_rails
spec/react_on_rails/generators Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -215,7 +215,8 @@ def rewrite_react_on_rails_module_specifiers(content)
215215 end
216216
217217 def line_continues_with_comma? ( line )
218- line . rstrip . match? ( /,\s *(?:#.*)?\z / )
218+ code_without_comment = line . sub ( /\s *#.*\z / , "" )
219+ code_without_comment . rstrip . end_with? ( "," )
219220 end
220221
221222 def print_success_message
Original file line number Diff line number Diff line change 193193 expect ( gemfile_content ) . not_to include ( "gem \" react_on_rails\" # pinned for compatibility" )
194194 expect ( generator ) . to have_received ( :bundle_install_after_gem_swap )
195195 end
196+
197+ it "does not treat trailing comment commas as multiline continuation" do
198+ simulate_existing_file ( "Gemfile" , <<~RUBY )
199+ source "https://rubygems.org"
200+ gem "react_on_rails" # keep this one,
201+ gem "rails"
202+ RUBY
203+ allow ( generator ) . to receive ( :bundle_install_after_gem_swap )
204+
205+ generator . send ( :swap_base_gem_for_pro_in_gemfile )
206+
207+ gemfile_content = File . read ( gemfile_path )
208+ expected_version = Gem ::Version . new ( ReactOnRails ::VERSION ) . release . to_s
209+ expect ( gemfile_content ) . to include ( "gem \" react_on_rails_pro\" , \" ~> #{ expected_version } \" " )
210+ expect ( gemfile_content ) . to include ( "gem \" rails\" " )
211+ expect ( generator ) . to have_received ( :bundle_install_after_gem_swap )
212+ end
196213 end
197214
198215 describe "#bundle_install_after_gem_swap" do
You can’t perform that action at this time.
0 commit comments