diff --git a/Changelog.md b/Changelog.md index 1d712bae..4c0f79a9 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,7 @@ +# v0.8.24 2018-12-xx + +* Change to always insert mutations with frozen string literals + # v0.8.23 2018-12-23 * Improved isolation error reporting diff --git a/lib/mutant/loader.rb b/lib/mutant/loader.rb index 15733ee5..27efb6ff 100644 --- a/lib/mutant/loader.rb +++ b/lib/mutant/loader.rb @@ -5,6 +5,10 @@ module Mutant class Loader include Anima.new(:binding, :kernel, :source, :subject) + FROZEN_STRING_FORMAT = "# frozen_string_literal: true\n%s" + + private_constant(*constants(false)) + # Call loader # # @return [self] @@ -19,7 +23,7 @@ module Mutant # @return [undefined] def call kernel.eval( - source, + FROZEN_STRING_FORMAT % source, binding, subject.source_path.to_s, subject.source_line diff --git a/spec/unit/mutant/loader_spec.rb b/spec/unit/mutant/loader_spec.rb index 7da08b5a..885397c8 100644 --- a/spec/unit/mutant/loader_spec.rb +++ b/spec/unit/mutant/loader_spec.rb @@ -29,7 +29,7 @@ RSpec.describe Mutant::Loader, '.call' do it 'performs expected kernel interaction' do expect(kernel).to receive(:eval) .with( - source, + "# frozen_string_literal: true\n#[InstanceDouble(String) (anonymous)]", binding, path_str, line