-
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PoC: Isolate dependency injections by specific pattern #59
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe "allow condition" do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
describe "allow" do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
before do | ||
module Test | ||
AutoInject = Dry::AutoInject({one: 1, two: 2}) | ||
timriley marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Redundant curly braces around a hash parameter. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Space inside } missing. |
||
OnlyOneInject = AutoInject.allow(/one/) | ||
end | ||
end | ||
|
||
subject(:instance) { including_class.new } | ||
|
||
context 'when user injects allowed keys' do | ||
let(:including_class) do | ||
Class.new do | ||
include Test::OnlyOneInject[:one] | ||
end | ||
end | ||
|
||
it { expect(instance.one).to eq 1 } | ||
timriley marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end | ||
|
||
context 'when user injects all keys' do | ||
let(:including_class) do | ||
Class.new do | ||
include Test::OnlyOneInject[:one, :two] | ||
end | ||
end | ||
|
||
it { expect { instance }.to raise_error } | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, it will be better to raise some fixed error, not
RuntimeError
. I think, it would be great for programmers. WDYT about it?