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 specs to cover the bug 9573 #879

Closed
wants to merge 2 commits into from
Closed
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
54 changes: 54 additions & 0 deletions language/module_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,57 @@ module ModuleSpecs::Modules::Klass; end
d.name.should == "ModuleSpecs_CS2::D"
end
end

ruby_version_is "3.0" do
describe "Include" do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move these specs to core/module/include_spec.rb and core/module/prepend_spec.rb?
language/ is for syntax, and include/prepend are just regular Ruby methods should should be tested in core/.

context "when the include in the module is done after the include in the class" do
it "includes the M1 and M2 module" do
class A; end
module B1; end
module C2; end

A.include B1
B1.include C2
A.ancestors.should == [A, B1, C2, Object, ModuleSpecs::IncludedInObject, PP::ObjectMixin, Kernel, BasicObject]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to only check the first 4 ancestors here, since there can be various modules included in Object and that we can't test here easily.
I think something like [A, B1, C2] + Object.ancestors is nice.

end
end

context "when the include in the module is done before the include in the class" do
it "includes the M1 and M2 module" do
class D; end
module E1; end
module F2; end

E1.include F2
D.include E1
D.ancestors.should == [D, E1, F2, Object, ModuleSpecs::IncludedInObject, PP::ObjectMixin, Kernel, BasicObject]
end
end
end

describe "Prepend" do
context "when the prepend in the module is done after the prepend in the class" do
it "prepends the M1 and M2 module" do
class G; end
module H1; end
module I2; end

G.prepend H1
H1.prepend I2
G.ancestors.should == [I2, H1, G, Object, ModuleSpecs::IncludedInObject, PP::ObjectMixin, Kernel, BasicObject]
end
end

context "when the prepend in the module is done before the prepend in the class" do
it "prepends the M1 and M2 module" do
class J; end
module K1; end
module L2; end

K1.prepend L2
J.prepend K1
J.ancestors.should == [L2, K1, J, Object, ModuleSpecs::IncludedInObject, PP::ObjectMixin, Kernel, BasicObject]
end
end
end
end