diff --git a/lib/mjml.rb b/lib/mjml.rb index 9fb7bee..6ace45e 100644 --- a/lib/mjml.rb +++ b/lib/mjml.rb @@ -76,6 +76,7 @@ def self.check_for_custom_mjml_binary def self.check_for_mjml_package(package_manager, bin_command, binary_path) stdout, _, status = Open3.capture3("which #{package_manager}") return unless status.success? + pm_bin = stdout.chomp stdout, _, status = Open3.capture3("#{pm_bin} #{bin_command}") @@ -94,14 +95,16 @@ def self.check_for_package_mjml_binary end def self.check_for_global_mjml_binary - stdout, _, status = Open3.capture3("which mjml") + stdout, _, status = Open3.capture3('which mjml') return unless status.success? + mjml_bin = stdout.chomp return mjml_bin if mjml_bin.present? && check_version(mjml_bin) end def self.check_for_mrml_binary return unless Mjml.use_mrml + MRML.present? rescue NameError Mjml.mjml_binary_error_string = 'Couldn\'t find MRML - did you add \'mrml\' to your Gemfile?' diff --git a/test/mjml_test.rb b/test/mjml_test.rb index 23e6850..86956d6 100644 --- a/test/mjml_test.rb +++ b/test/mjml_test.rb @@ -173,14 +173,14 @@ class NotifierMailerTest < ActiveSupport::TestCase expect(Mjml.mjml_binary_error_string).must_equal 'Couldn\'t find MRML - did you add \'mrml\' to your Gemfile?' end - it "with nothing on the path, sets valid_mjml_binary to nil" do - old_path = ENV["PATH"] - ENV["PATH"] = "./test/fixtures/valid-mjml-binary/empty-path/" + it 'with nothing on the path, sets valid_mjml_binary to nil' do + old_path = ENV['PATH'] + ENV['PATH'] = './test/fixtures/valid-mjml-binary/empty-path/' Mjml.stubs(:puts) # silence printed error message from test output assert_nil(Mjml.valid_mjml_binary) ensure - ENV["PATH"] = old_path + ENV['PATH'] = old_path end end end