Skip to content

Commit

Permalink
Revert "Changed load_class_from_file to use load to force reloadi…
Browse files Browse the repository at this point in the history
…ng the file."

* This reverts commit bbeb41b.
* This change does not handle the edge-case where the class has already
  been loaded and it's id is still in the `.registry`.
  • Loading branch information
postmodern committed Jun 4, 2024
1 parent bbeb41b commit 6e50c2c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/ronin/core/class_registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def load_class_from_file(file)

previous_entries = registry.keys

load(file)
require(file)

new_entries = registry.keys - previous_entries

Expand Down
11 changes: 5 additions & 6 deletions spec/class_registry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,10 @@ class Foo
let(:file) { File.join(subject.class_dir,"#{id}.rb") }
let(:klass) { ExampleClassRegistry::LoadedClass }

it "must load the file" do
expect(subject).to receive(:load).with(file) do
load(file)
end

it "must require the file" do
subject.load_class_from_file(file)

expect($LOADED_FEATURES).to include(file)
end

it "must return the registered module" do
Expand All @@ -128,7 +126,7 @@ class Foo
let(:absolute_path) { File.expand_path(relative_path) }

it "must expand the path first" do
expect(subject).to receive(:load).with(absolute_path) do
expect(subject).to receive(:require).with(absolute_path) do
load(absolute_path)
end

Expand Down Expand Up @@ -160,6 +158,7 @@ class Foo

after do
subject.registry.clear
$LOADED_FEATURES.delete(file)
end
end

Expand Down

0 comments on commit 6e50c2c

Please sign in to comment.