From 6dc898a6553964184e486fa2c94e3ed5fdb28429 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Mikul=C3=A1=C5=A1ek?= Date: Thu, 16 Apr 2020 08:52:12 +0200 Subject: [PATCH] Fix last version to strip also newlines --- lib/puppet/functions/rclone/last_version.rb | 2 +- spec/classes/rclone_spec.rb | 2 +- spec/functions/last_version_spec.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/puppet/functions/rclone/last_version.rb b/lib/puppet/functions/rclone/last_version.rb index c247d74..2b5c425 100644 --- a/lib/puppet/functions/rclone/last_version.rb +++ b/lib/puppet/functions/rclone/last_version.rb @@ -11,7 +11,7 @@ def last_version uri = URI('https://downloads.rclone.org/version.txt') Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http| response = http.request Net::HTTP::Get.new(uri) - response.body.gsub(%r{.*rclone v(\d+\.\d+\.\d+).*}, '\1') + response.body.gsub(%r{.*rclone v(\d+\.\d+\.\d+).*}m, '\1') end end end diff --git a/spec/classes/rclone_spec.rb b/spec/classes/rclone_spec.rb index 0588aef..ca9901d 100644 --- a/spec/classes/rclone_spec.rb +++ b/spec/classes/rclone_spec.rb @@ -23,7 +23,7 @@ let(:params) { { ensure: 'latest' } } before(:each) do - stub_request(:get, 'https://downloads.rclone.org/version.txt').to_return(body: 'rclone v1000.0.1') + stub_request(:get, 'https://downloads.rclone.org/version.txt').to_return(body: "rclone v1000.0.1\n") end it { is_expected.to contain_class('rclone::install') } diff --git a/spec/functions/last_version_spec.rb b/spec/functions/last_version_spec.rb index 9a093e9..0a61e65 100644 --- a/spec/functions/last_version_spec.rb +++ b/spec/functions/last_version_spec.rb @@ -4,7 +4,7 @@ describe 'rclone::last_version' do before(:each) do - stub_request(:get, 'https://downloads.rclone.org/version.txt').to_return(body: 'rclone v1000.0.1') + stub_request(:get, 'https://downloads.rclone.org/version.txt').to_return(body: "rclone v1000.0.1\n") end it { is_expected.to run.and_return('1000.0.1') }