Skip to content

Commit

Permalink
return false instead of to make consistent result.
Browse files Browse the repository at this point in the history
  • Loading branch information
eudoxa committed Dec 5, 2022
1 parent 11bc393 commit ef1da3c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/chanko/loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def load
constantize
rescue NameError
# Chanko never raise error even if the constant fails to reference
nil
false
end

def constantize
Expand Down Expand Up @@ -125,7 +125,7 @@ def load_from_file_and_store_to_cache
rescue Exception => exception
ExceptionHandler.handle(exception)
self.class.save_to_cache(@name, false)
nil
false
end

def load_from_cache
Expand Down
10 changes: 5 additions & 5 deletions spec/chanko/loader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ module Chanko

context "when non-existent unit name is passed" do
it "returns nil" do
expect(Chanko::Loader.load(:non_existent_unit)).to eq(nil)
expect(Chanko::Loader.load(:non_existent_unit)).to eq(false)
end
end

context "when loader has ever loaded specified unit" do
it "load unit from cache", classic: true do
expect(Chanko::Loader::ClassicLoader).to receive(:load_from_cache).twice.and_call_original
expect(Chanko::Loader::ClassicLoader).to receive(:save_to_cache).with(anything, ExampleUnit).and_call_original
Chanko::Loader.load(:example_unit)
Chanko::Loader.load(:example_unit)
expect(Chanko::Loader.load(:example_unit)).to eq(ExampleUnit)
expect(Chanko::Loader.load(:example_unit)).to eq(ExampleUnit)
end
end

Expand All @@ -36,8 +36,8 @@ module Chanko
it "load unit from cache", classic: true do
expect(Chanko::Loader::ClassicLoader).to receive(:load_from_cache).twice.and_call_original
expect(Chanko::Loader::ClassicLoader).to receive(:save_to_cache).with(anything, false).and_call_original
Chanko::Loader.load(:non_existent_unit)
Chanko::Loader.load(:non_existent_unit)
expect(Chanko::Loader.load(:non_existent_unit)).to eq(false)
expect(Chanko::Loader.load(:non_existent_unit)).to eq(false)
end
end
end
Expand Down

0 comments on commit ef1da3c

Please sign in to comment.