Skip to content
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

Add more tests for hooks inheritance #1

Open
wants to merge 1 commit into
base: hooks-inheritance
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions spec/interactor/hooks_spec.rb
Original file line number Diff line number Diff line change
@@ -364,11 +364,16 @@ def add_after2
}

let(:inherited) { Class.new(hooked) }
let(:deeply_inherited) { Class.new(Class.new(inherited)) }

it "inherites around hooks from parent class" do
it "inherits around hooks from parent class" do
expect(inherited.around_hooks).to eq(hooked.around_hooks)
end

it "inherits around hooks from all ancestor classes" do
expect(deeply_inherited.around_hooks).to eq(hooked.around_hooks)
end

it "does not add hook to parent class" do
inherited.class_eval { around { |hooked| hooked.call } }
expect(inherited.around_hooks.size).not_to eq(hooked.around_hooks.size)
@@ -384,11 +389,16 @@ def add_after2
}

let(:inherited) { Class.new(hooked) }
let(:deeply_inherited) { Class.new(Class.new(inherited)) }

it "inherites before hooks from parent class" do
it "inherits before hooks from parent class" do
expect(inherited.before_hooks).to eq(hooked.before_hooks)
end

it "inherits before hooks from all ancestor classes" do
expect(deeply_inherited.before_hooks).to eq(hooked.before_hooks)
end

it "does not add hook to parent class" do
inherited.class_eval { before {} }
expect(inherited.before_hooks).not_to eq(hooked.before_hooks)
@@ -404,11 +414,16 @@ def add_after2
}

let(:inherited) { Class.new(hooked) }
let(:deeply_inherited) { Class.new(Class.new(inherited)) }

it "inherites after hooks from parent class" do
it "inherits after hooks from parent class" do
expect(inherited.after_hooks).to eq(hooked.after_hooks)
end

it "inherits after hooks from all ancestor classes" do
expect(deeply_inherited.before_hooks).to eq(hooked.before_hooks)
end

it "does not add hook to parent class" do
inherited.class_eval { after {} }
expect(inherited.after_hooks).not_to eq(hooked.after_hooks)