-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix and write specs, fix bugs, change minimal ruby version
- Loading branch information
1 parent
3a674f9
commit c179520
Showing
18 changed files
with
425 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
module Resol | ||
module Plugins | ||
module Dummy; end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe Resol::Configuration do | ||
before { allow(described_class).to receive(:smart_not_loaded?).and_return(const_not_loaded?) } | ||
|
||
let(:const_not_loaded?) { true } | ||
|
||
it "#smart_config returns nil" do | ||
expect(described_class.smart_config).to eq(nil) | ||
end | ||
|
||
context "with loaded const" do | ||
let(:const_not_loaded?) { false } | ||
|
||
it "returns config" do | ||
expect(described_class.smart_config).to eq(SmartCore::Initializer::Configuration.config) | ||
end | ||
end | ||
|
||
context "with original method" do | ||
before { allow(described_class).to receive(:smart_not_loaded?).and_call_original } | ||
|
||
it "returns smartcore config" do | ||
expect(described_class.smart_config).to eq(SmartCore::Initializer::Configuration.config) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,83 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe Resol::Initializers do | ||
def apply_initializer(forced_service_class = nil) | ||
described_class.apply!(forced_service_class || service_class, initializer_name) | ||
end | ||
|
||
before { stub_const("InitializerTestClass", service_class) } | ||
|
||
let(:service_class) do | ||
Class.new(Resol::Service) do | ||
def call | ||
success! | ||
end | ||
end | ||
end | ||
|
||
let(:initializer_name) { :dry } | ||
let(:dry_modules) do | ||
["Dry::Initializer::Mixin::Root", start_with("Dry::Initializer::Mixin::Local")] | ||
end | ||
|
||
it "properly extend service class with initializer" do | ||
apply_initializer | ||
expect(service_class.ancestors.map(&:to_s)).to include(*dry_modules) | ||
end | ||
|
||
context "with unknown initializer lib" do | ||
let(:initializer_name) { :kek } | ||
|
||
specify do | ||
expect { apply_initializer }.to raise_error(ArgumentError, "unknown initializer kek") | ||
end | ||
end | ||
|
||
context "with already prepared parent" do | ||
before { stub_const("SecondChildService", second_child_service) } | ||
|
||
let(:service_class) do | ||
Class.new(ReturnEngineService) do | ||
def call | ||
success! | ||
end | ||
end | ||
end | ||
|
||
let(:second_child_service) do | ||
Class.new(InitializerTestClass) | ||
end | ||
|
||
let(:error_message) do | ||
"ReturnEngineService or his superclasses already used initialize lib" | ||
end | ||
|
||
specify do | ||
expect { apply_initializer(SecondChildService) }.to raise_error(ArgumentError, error_message) | ||
end | ||
end | ||
|
||
context "with manually extended service" do | ||
before { stub_const("SecondChildService", second_child_service) } | ||
|
||
let(:service_class) do | ||
Class.new(Resol::Service) do | ||
extend Dry::Initializer | ||
|
||
def call | ||
success! | ||
end | ||
end | ||
end | ||
|
||
let(:second_child_service) do | ||
Class.new(InitializerTestClass) | ||
end | ||
|
||
let(:error_message) { "use ::use_initializer! method on desired service class" } | ||
|
||
specify do | ||
expect { apply_initializer(SecondChildService) }.to raise_error(ArgumentError, error_message) | ||
end | ||
end | ||
end |
Oops, something went wrong.