evilution 0.22.3 → 0.22.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 05657264e506e5a6b5041d68b5eb46bfcbbf9a17780caeb3c44feaf5f5d18794
4
- data.tar.gz: a7e6333fc26d21799b3807d3fbc2758ae54e00de2c7f1028e5ad30cf8777e8d2
3
+ metadata.gz: 8dfc39a794faace7567c4539876cb9c331cba15f62420625aafc8adf9d3fb7bf
4
+ data.tar.gz: e199a8d90e70db722e76fe785968385dc1725297ee6020b31760fdfad5745c70
5
5
  SHA512:
6
- metadata.gz: 8d791eba8e795dcaa34c6ff3cc82a4b9653cfc282fcff1f7a75911bdfbd192689d21324ad793077700644a497c8320b2fb77e874bff63cd98c1a788390a27309
7
- data.tar.gz: 5ee22113b3b0343c60c08ca4c4c4160492617827376c783fbe0052d5a5a59ab37199fc16de349502c6c7d26f2c64814abf7ad31228e325dcdc1be86e1a7930d7
6
+ metadata.gz: 32d62ef27f34042244512d5d52082c4a53d82b0f6de91e924faebd8317d5d2d8c57a5fa53b8b5f3cc6bee325723e62dcfbd0b32d9bc8c2b17f368cde027a93b1
7
+ data.tar.gz: c4695099eb10bbdd2f69995fa95f3f9dcb8dbb3497532758b9177594fb9e098021080924276cf582c5b951dc95e6af39d1d7e2d1fae404f2e451bf8622fefa39
data/CHANGELOG.md CHANGED
@@ -1,10 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.22.5] - 2026-04-12
4
+
5
+ ### Fixed
6
+
7
+ - **`ActiveSupport::Concern` modules: all mutations error with `MultipleIncludedBlocks`** — re-evaluating a mutated concern file triggered Rails' guard because `@_included_block` (and `@_prepended_block`) was already set from the original load with a different `source_location`; now `clear_concern_state` removes these instance variables from affected concern modules before `require`/`load`, matching both original file paths and temp-dir copies via subpath suffix so consecutive mutations of the same concern also succeed (#676, PR #678)
8
+
9
+ ## [0.22.4] - 2026-04-12
10
+
11
+ ### Fixed
12
+
13
+ - **`LoadError: cannot load such file -- spec_helper` during preload** — `perform_preload` ran before `ensure_framework_loaded`, so `spec/` was not on `$LOAD_PATH` and `rspec/core` was not loaded when `rails_helper.rb` tried to `require 'spec_helper'` and call `RSpec.configure`; now `prepare_load_path_for_preload` adds `spec/` to `$LOAD_PATH` and loads `rspec/core` before the preload file; errors (e.g. missing `rspec-core` gem) propagate as `ConfigError` with clear context (#669, #673)
14
+
3
15
  ## [0.22.3] - 2026-04-12
4
16
 
5
17
  ### Fixed
6
18
 
7
- - **`LoadError: cannot load such file -- spec_helper`** — projects with `--require spec_helper` in `.rspec` failed on every mutation because `spec/` was not on `$LOAD_PATH`; RSpec's CLI normally adds it, but evilution calls `RSpec::Core::Runner.run` directly, bypassing the CLI; now adds `spec/` to `$LOAD_PATH` in both `ensure_framework_loaded` and `baseline_runner` (#669)
19
+ - **`LoadError: cannot load such file -- spec_helper`** — projects with `--require spec_helper` in `.rspec` failed on every mutation because `spec/` was not on `$LOAD_PATH`; RSpec's CLI normally adds it, but evilution calls `RSpec::Core::Runner.run` directly, bypassing the CLI; now adds `spec/` to `$LOAD_PATH` in `ensure_framework_loaded`, `baseline_runner`, and `perform_preload`; also loads `rspec/core` before preloading so that `spec_helper.rb` can use `RSpec.configure` (#669)
8
20
 
9
21
  ## [0.22.2] - 2026-04-12
10
22
 
@@ -87,6 +87,7 @@ class Evilution::Integration::Base
87
87
  File.write(dest, mutation.mutated_source)
88
88
  $LOAD_PATH.unshift(@temp_dir)
89
89
  displace_loaded_feature(mutation.file_path)
90
+ clear_concern_state(mutation.file_path)
90
91
  require(subpath.delete_suffix(".rb"))
91
92
  end
92
93
 
@@ -95,6 +96,7 @@ class Evilution::Integration::Base
95
96
  dest = File.join(@temp_dir, absolute)
96
97
  FileUtils.mkdir_p(File.dirname(dest))
97
98
  File.write(dest, mutation.mutated_source)
99
+ clear_concern_state(mutation.file_path)
98
100
  load(dest)
99
101
  end
100
102
 
@@ -110,6 +112,35 @@ class Evilution::Integration::Base
110
112
  @temp_dir = nil
111
113
  end
112
114
 
115
+ def clear_concern_state(file_path)
116
+ return unless defined?(ActiveSupport::Concern)
117
+
118
+ absolute = File.expand_path(file_path)
119
+ subpath = resolve_require_subpath(file_path)
120
+
121
+ ObjectSpace.each_object(Module) do |mod|
122
+ next unless mod.singleton_class.ancestors.include?(ActiveSupport::Concern)
123
+
124
+ %i[@_included_block @_prepended_block].each do |ivar|
125
+ next unless mod.instance_variable_defined?(ivar)
126
+
127
+ block = mod.instance_variable_get(ivar)
128
+ block_file = block.source_location&.first
129
+ next unless block_file
130
+
131
+ expanded = File.expand_path(block_file)
132
+ mod.remove_instance_variable(ivar) if source_matches?(expanded, absolute, subpath)
133
+ end
134
+ end
135
+ end
136
+
137
+ def source_matches?(block_path, absolute, subpath)
138
+ return true if block_path == absolute
139
+ return true if subpath && block_path.end_with?("/#{subpath}")
140
+
141
+ false
142
+ end
143
+
113
144
  def resolve_require_subpath(file_path)
114
145
  absolute = File.expand_path(file_path)
115
146
  best_subpath = nil
@@ -528,6 +528,7 @@ class Evilution::Runner
528
528
  path = resolve_preload_path
529
529
  return unless path
530
530
 
531
+ prepare_load_path_for_preload
531
532
  require File.expand_path(path)
532
533
  rescue ScriptError, StandardError => e
533
534
  raise Evilution::ConfigError.new(
@@ -536,6 +537,23 @@ class Evilution::Runner
536
537
  )
537
538
  end
538
539
 
540
+ # Preload files (e.g. spec/rails_helper.rb) typically `require 'spec_helper'`
541
+ # which needs spec/ on $LOAD_PATH, and use `RSpec.configure` which needs
542
+ # rspec/core loaded. The RSpec CLI normally sets this up, but evilution
543
+ # calls Runner.run directly.
544
+ def prepare_load_path_for_preload
545
+ spec_dir = File.expand_path(resolve_spec_dir)
546
+ $LOAD_PATH.unshift(spec_dir) unless $LOAD_PATH.include?(spec_dir)
547
+ require "rspec/core" if config.integration == :rspec
548
+ end
549
+
550
+ def resolve_spec_dir
551
+ root = detected_rails_root
552
+ return File.join(root, "spec") if root
553
+
554
+ "spec"
555
+ end
556
+
539
557
  def resolve_preload_path
540
558
  if config.preload.is_a?(String)
541
559
  unless File.file?(config.preload)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Evilution
4
- VERSION = "0.22.3"
4
+ VERSION = "0.22.5"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evilution
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.3
4
+ version: 0.22.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Kiselev