Use frozen string literal feature when running tests

This commit is contained in:
Ali Ismayilov 2020-07-13 18:46:18 +02:00
parent 33ca30a881
commit 295ded4f2a
2 changed files with 19 additions and 16 deletions

View File

@ -1,20 +1,21 @@
language: ruby
rvm:
- 1.9.3
- 2.0.0
- 2.1
- 2.2
- 2.3
- 2.4
- 2.5
- ruby-head
- jruby-19mode
- rbx-3
jobs:
include:
- rvm: 1.9.3
- rvm: 2.0.0
- rvm: 2.1
- rvm: 2.2
- rvm: 2.3
- rvm: 2.4
env: RUBYOPT="--enable-frozen-string-literal"
- rvm: 2.5
env: RUBYOPT="--enable-frozen-string-literal"
- rvm: ruby-head
env: RUBYOPT="--enable-frozen-string-literal"
before_install:
# 1. The pre-installed Bundler version on Travis is very old; causes 1.9.3 build issues
# 2. Bundler 2.0 is not supported by the whole matrix
- gem install bundler -v'< 2'
matrix:
allow_failures:
- rvm: ruby-head
- rvm: rbx-3
script:
- bundle exec rake

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'mimemagic/tables'
require 'mimemagic/version'
@ -113,7 +115,7 @@ class MimeMagic
io.binmode if io.respond_to?(:binmode)
io.set_encoding(Encoding::BINARY) if io.respond_to?(:set_encoding)
buffer = "".force_encoding(Encoding::BINARY)
buffer = "".encode(Encoding::BINARY)
MAGIC.send(method) { |type, matches| magic_match_io(io, matches, buffer) }
end