summaryrefslogtreecommitdiff
path: root/spec/ruby/core/module/protected_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/module/protected_spec.rb')
-rw-r--r--spec/ruby/core/module/protected_spec.rb38
1 files changed, 13 insertions, 25 deletions
diff --git a/spec/ruby/core/module/protected_spec.rb b/spec/ruby/core/module/protected_spec.rb
index 058d49d751..3ef6c76fae 100644
--- a/spec/ruby/core/module/protected_spec.rb
+++ b/spec/ruby/core/module/protected_spec.rb
@@ -18,7 +18,7 @@ describe "Module#protected" do
protected :protected_method_1
end
- -> { ModuleSpecs::Parent.protected_method_1 }.should raise_error(NoMethodError)
+ -> { ModuleSpecs::Parent.protected_method_1 }.should.raise(NoMethodError)
end
it "makes a public Object instance method protected in a new module" do
@@ -26,44 +26,32 @@ describe "Module#protected" do
protected :module_specs_public_method_on_object
end
- m.should have_protected_instance_method(:module_specs_public_method_on_object)
+ m.protected_instance_methods(false).should.include?(:module_specs_public_method_on_object)
# Ensure we did not change Object's method
- Object.should_not have_protected_instance_method(:module_specs_public_method_on_object)
+ Object.protected_instance_methods(true).should_not.include?(:module_specs_public_method_on_object)
end
it "makes a public Object instance method protected in Kernel" do
- Kernel.should have_protected_instance_method(
+ Kernel.protected_instance_methods(false).should.include?(
:module_specs_public_method_on_object_for_kernel_protected)
- Object.should_not have_protected_instance_method(
+ Object.protected_instance_methods(true).should_not.include?(
:module_specs_public_method_on_object_for_kernel_protected)
end
- ruby_version_is ""..."3.1" do
- it "returns self" do
- (class << Object.new; self; end).class_eval do
- def foo; end
- protected(:foo).should equal(self)
- protected.should equal(self)
- end
- end
- end
-
- ruby_version_is "3.1" do
- it "returns argument or arguments if given" do
- (class << Object.new; self; end).class_eval do
- def foo; end
- protected(:foo).should equal(:foo)
- protected([:foo, :foo]).should == [:foo, :foo]
- protected(:foo, :foo).should == [:foo, :foo]
- protected.should equal(nil)
- end
+ it "returns argument or arguments if given" do
+ (class << Object.new; self; end).class_eval do
+ def foo; end
+ protected(:foo).should.equal?(:foo)
+ protected([:foo, :foo]).should == [:foo, :foo]
+ protected(:foo, :foo).should == [:foo, :foo]
+ protected.should.equal?(nil)
end
end
it "raises a NameError when given an undefined name" do
-> do
Module.new.send(:protected, :undefined)
- end.should raise_error(NameError)
+ end.should.raise(NameError)
end
end