summaryrefslogtreecommitdiff
path: root/spec/ruby/core/main
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/main')
-rw-r--r--spec/ruby/core/main/define_method_spec.rb6
-rw-r--r--spec/ruby/core/main/include_spec.rb4
-rw-r--r--spec/ruby/core/main/private_spec.rb14
-rw-r--r--spec/ruby/core/main/public_spec.rb14
-rw-r--r--spec/ruby/core/main/ruby2_keywords_spec.rb2
-rw-r--r--spec/ruby/core/main/using_spec.rb22
6 files changed, 30 insertions, 32 deletions
diff --git a/spec/ruby/core/main/define_method_spec.rb b/spec/ruby/core/main/define_method_spec.rb
index d85c5e8119..5279d078c3 100644
--- a/spec/ruby/core/main/define_method_spec.rb
+++ b/spec/ruby/core/main/define_method_spec.rb
@@ -14,15 +14,15 @@ describe "main#define_method" do
it 'creates a public method in TOPLEVEL_BINDING' do
eval @code, TOPLEVEL_BINDING
- Object.should have_method :boom
+ Object.should.respond_to? :boom
end
it 'creates a public method in script binding' do
eval @code, script_binding
- Object.should have_method :boom
+ Object.should.respond_to? :boom
end
it 'returns the method name as symbol' do
- eval(@code, TOPLEVEL_BINDING).should equal :boom
+ eval(@code, TOPLEVEL_BINDING).should.equal? :boom
end
end
diff --git a/spec/ruby/core/main/include_spec.rb b/spec/ruby/core/main/include_spec.rb
index 9f5a5f54ea..09f8d4d3b5 100644
--- a/spec/ruby/core/main/include_spec.rb
+++ b/spec/ruby/core/main/include_spec.rb
@@ -4,13 +4,13 @@ require_relative 'fixtures/classes'
describe "main#include" do
it "includes the given Module in Object" do
eval "include MainSpecs::Module", TOPLEVEL_BINDING
- Object.ancestors.should include(MainSpecs::Module)
+ Object.ancestors.should.include?(MainSpecs::Module)
end
context "in a file loaded with wrapping" do
it "includes the given Module in the load wrapper" do
load(File.expand_path("../fixtures/wrapped_include.rb", __FILE__), true)
- Object.ancestors.should_not include(MainSpecs::WrapIncludeModule)
+ Object.ancestors.should_not.include?(MainSpecs::WrapIncludeModule)
end
end
end
diff --git a/spec/ruby/core/main/private_spec.rb b/spec/ruby/core/main/private_spec.rb
index 76895fd649..56a39ae3c1 100644
--- a/spec/ruby/core/main/private_spec.rb
+++ b/spec/ruby/core/main/private_spec.rb
@@ -10,33 +10,33 @@ describe "main#private" do
context "when single argument is passed and it is not an array" do
it "sets the visibility of the given methods to private" do
eval "private :main_public_method", TOPLEVEL_BINDING
- Object.should have_private_method(:main_public_method)
+ Object.private_methods(true).should.include?(:main_public_method)
end
end
context "when multiple arguments are passed" do
it "sets the visibility of the given methods to private" do
eval "private :main_public_method, :main_public_method2", TOPLEVEL_BINDING
- Object.should have_private_method(:main_public_method)
- Object.should have_private_method(:main_public_method2)
+ Object.private_methods(true).should.include?(:main_public_method)
+ Object.private_methods(true).should.include?(:main_public_method2)
end
end
context "when single argument is passed and is an array" do
it "sets the visibility of the given methods to private" do
eval "private [:main_public_method, :main_public_method2]", TOPLEVEL_BINDING
- Object.should have_private_method(:main_public_method)
- Object.should have_private_method(:main_public_method2)
+ Object.private_methods(true).should.include?(:main_public_method)
+ Object.private_methods(true).should.include?(:main_public_method2)
end
end
it "returns argument" do
- eval("private :main_public_method", TOPLEVEL_BINDING).should equal(:main_public_method)
+ eval("private :main_public_method", TOPLEVEL_BINDING).should.equal?(:main_public_method)
end
it "raises a NameError when at least one of given method names is undefined" do
-> do
eval "private :main_public_method, :main_undefined_method", TOPLEVEL_BINDING
- end.should raise_error(NameError)
+ end.should.raise(NameError)
end
end
diff --git a/spec/ruby/core/main/public_spec.rb b/spec/ruby/core/main/public_spec.rb
index 3c77798fbc..89368ebb0d 100644
--- a/spec/ruby/core/main/public_spec.rb
+++ b/spec/ruby/core/main/public_spec.rb
@@ -10,34 +10,34 @@ describe "main#public" do
context "when single argument is passed and it is not an array" do
it "sets the visibility of the given methods to public" do
eval "public :main_private_method", TOPLEVEL_BINDING
- Object.should_not have_private_method(:main_private_method)
+ Object.private_methods(true).should_not.include?(:main_private_method)
end
end
context "when multiple arguments are passed" do
it "sets the visibility of the given methods to public" do
eval "public :main_private_method, :main_private_method2", TOPLEVEL_BINDING
- Object.should_not have_private_method(:main_private_method)
- Object.should_not have_private_method(:main_private_method2)
+ Object.private_methods(true).should_not.include?(:main_private_method)
+ Object.private_methods(true).should_not.include?(:main_private_method2)
end
end
context "when single argument is passed and is an array" do
it "sets the visibility of the given methods to public" do
eval "public [:main_private_method, :main_private_method2]", TOPLEVEL_BINDING
- Object.should_not have_private_method(:main_private_method)
- Object.should_not have_private_method(:main_private_method2)
+ Object.private_methods(true).should_not.include?(:main_private_method)
+ Object.private_methods(true).should_not.include?(:main_private_method2)
end
end
it "returns argument" do
- eval("public :main_private_method", TOPLEVEL_BINDING).should equal(:main_private_method)
+ eval("public :main_private_method", TOPLEVEL_BINDING).should.equal?(:main_private_method)
end
it "raises a NameError when given an undefined name" do
-> do
eval "public :main_undefined_method", TOPLEVEL_BINDING
- end.should raise_error(NameError)
+ end.should.raise(NameError)
end
end
diff --git a/spec/ruby/core/main/ruby2_keywords_spec.rb b/spec/ruby/core/main/ruby2_keywords_spec.rb
index 27ceae3253..d12c0ed4e4 100644
--- a/spec/ruby/core/main/ruby2_keywords_spec.rb
+++ b/spec/ruby/core/main/ruby2_keywords_spec.rb
@@ -4,6 +4,6 @@ require_relative 'fixtures/classes'
describe "main.ruby2_keywords" do
it "is the same as Object.ruby2_keywords" do
main = TOPLEVEL_BINDING.receiver
- main.should have_private_method(:ruby2_keywords)
+ main.private_methods(false).should.include?(:ruby2_keywords)
end
end
diff --git a/spec/ruby/core/main/using_spec.rb b/spec/ruby/core/main/using_spec.rb
index 8a23970c4b..314a6be416 100644
--- a/spec/ruby/core/main/using_spec.rb
+++ b/spec/ruby/core/main/using_spec.rb
@@ -5,11 +5,11 @@ describe "main.using" do
it "requires one Module argument" do
-> do
eval('using', TOPLEVEL_BINDING)
- end.should raise_error(ArgumentError)
+ end.should.raise(ArgumentError)
-> do
eval('using "foo"', TOPLEVEL_BINDING)
- end.should raise_error(TypeError)
+ end.should.raise(TypeError)
end
it "uses refinements from the given module only in the target file" do
@@ -19,7 +19,7 @@ describe "main.using" do
MainSpecs::DATA[:toplevel].should == 'foo'
-> do
'hello'.foo
- end.should raise_error(NoMethodError)
+ end.should.raise(NoMethodError)
end
it "uses refinements from the given module for method calls in the target file" do
@@ -27,7 +27,7 @@ describe "main.using" do
load File.expand_path('../fixtures/string_refinement_user.rb', __FILE__)
-> do
'hello'.foo
- end.should raise_error(NoMethodError)
+ end.should.raise(NoMethodError)
MainSpecs.call_foo('hello').should == 'foo'
end
@@ -133,20 +133,18 @@ describe "main.using" do
it "raises error when called from method in wrapped script" do
-> do
load File.expand_path('../fixtures/using_in_method.rb', __FILE__), true
- end.should raise_error(RuntimeError)
+ end.should.raise(RuntimeError)
end
it "raises error when called on toplevel from module" do
-> do
load File.expand_path('../fixtures/using_in_main.rb', __FILE__), true
- end.should raise_error(RuntimeError)
+ end.should.raise(RuntimeError)
end
- ruby_version_is "3.2" do
- it "does not raise error when wrapped with module" do
- -> do
- load File.expand_path('../fixtures/using.rb', __FILE__), true
- end.should_not raise_error
- end
+ it "does not raise error when wrapped with module" do
+ -> do
+ load File.expand_path('../fixtures/using.rb', __FILE__), true
+ end.should_not.raise
end
end