diff --git a/Rakefile b/Rakefile index 7fda20b..8718663 100644 --- a/Rakefile +++ b/Rakefile @@ -36,10 +36,9 @@ end desc "Output the Rubygems version for a given binary" task :rubygems_version, [:version, :stack] do |t, args| - command = DockerCommand.gem_version_from_tar( stack: args[:stack], - ruby_version: RubyVersion.new(args[:version]), + ruby_version: RubyVersion.new(args[:version]) ) puts "Running: #{command}" pipe(command) diff --git a/lib/docker_command.rb b/lib/docker_command.rb index 0ae9437..95159ae 100644 --- a/lib/docker_command.rb +++ b/lib/docker_command.rb @@ -1,5 +1,5 @@ module DockerCommand - def self.gem_version_from_tar(ruby_version: , stack: ) + def self.gem_version_from_tar(ruby_version:, stack:) "docker run -v $(pwd)/builds/#{stack}:/tmp/output hone/ruby-builder:#{stack} bash -c \"mkdir /tmp/unzipped && tar xzf /tmp/output/#{ruby_version.tar_file_name_output} -C /tmp/unzipped && echo 'Rubygems version is: ' && /tmp/unzipped/bin/gem -v\"" end end diff --git a/spec/unit/docker_command_spec.rb b/spec/unit/docker_command_spec.rb index 124337e..aac2818 100644 --- a/spec/unit/docker_command_spec.rb +++ b/spec/unit/docker_command_spec.rb @@ -4,13 +4,13 @@ describe DockerCommand do it "Generates docker command for outputting rubygems versions" do actual = DockerCommand.gem_version_from_tar(ruby_version: RubyVersion.new("3.1.4"), stack: "heroku-22") - expected = %Q{docker run -v $(pwd)/builds/heroku-22:/tmp/output hone/ruby-builder:heroku-22 bash -c "mkdir /tmp/unzipped && tar xzf /tmp/output/ruby-3.1.4.tgz -C /tmp/unzipped && echo 'Rubygems version is: ' && /tmp/unzipped/bin/gem -v"} + expected = %{docker run -v $(pwd)/builds/heroku-22:/tmp/output hone/ruby-builder:heroku-22 bash -c "mkdir /tmp/unzipped && tar xzf /tmp/output/ruby-3.1.4.tgz -C /tmp/unzipped && echo 'Rubygems version is: ' && /tmp/unzipped/bin/gem -v"} expect(actual).to eq(expected) end it "works with preview releases" do actual = DockerCommand.gem_version_from_tar(ruby_version: RubyVersion.new("3.3.0-preview2"), stack: "heroku-22") - expected = %Q{docker run -v $(pwd)/builds/heroku-22:/tmp/output hone/ruby-builder:heroku-22 bash -c "mkdir /tmp/unzipped && tar xzf /tmp/output/ruby-3.3.0.tgz -C /tmp/unzipped && echo 'Rubygems version is: ' && /tmp/unzipped/bin/gem -v"} + expected = %{docker run -v $(pwd)/builds/heroku-22:/tmp/output hone/ruby-builder:heroku-22 bash -c "mkdir /tmp/unzipped && tar xzf /tmp/output/ruby-3.3.0.tgz -C /tmp/unzipped && echo 'Rubygems version is: ' && /tmp/unzipped/bin/gem -v"} expect(actual).to eq(expected) end end