summaryrefslogtreecommitdiff
path: root/spec/ruby/core/module
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/module')
-rw-r--r--spec/ruby/core/module/alias_method_spec.rb16
-rw-r--r--spec/ruby/core/module/append_features_spec.rb8
-rw-r--r--spec/ruby/core/module/attr_accessor_spec.rb10
-rw-r--r--spec/ruby/core/module/attr_reader_spec.rb8
-rw-r--r--spec/ruby/core/module/attr_spec.rb14
-rw-r--r--spec/ruby/core/module/attr_writer_spec.rb8
-rw-r--r--spec/ruby/core/module/autoload_spec.rb32
-rw-r--r--spec/ruby/core/module/class_variable_defined_spec.rb8
-rw-r--r--spec/ruby/core/module/class_variable_get_spec.rb16
-rw-r--r--spec/ruby/core/module/class_variable_set_spec.rb12
-rw-r--r--spec/ruby/core/module/const_defined_spec.rb16
-rw-r--r--spec/ruby/core/module/const_get_spec.rb44
-rw-r--r--spec/ruby/core/module/const_missing_spec.rb2
-rw-r--r--spec/ruby/core/module/const_set_spec.rb20
-rw-r--r--spec/ruby/core/module/define_method_spec.rb92
-rw-r--r--spec/ruby/core/module/define_singleton_method_spec.rb2
-rw-r--r--spec/ruby/core/module/deprecate_constant_spec.rb14
-rw-r--r--spec/ruby/core/module/extend_object_spec.rb4
-rw-r--r--spec/ruby/core/module/gt_spec.rb2
-rw-r--r--spec/ruby/core/module/gte_spec.rb2
-rw-r--r--spec/ruby/core/module/include_spec.rb12
-rw-r--r--spec/ruby/core/module/instance_method_spec.rb12
-rw-r--r--spec/ruby/core/module/lt_spec.rb2
-rw-r--r--spec/ruby/core/module/lte_spec.rb2
-rw-r--r--spec/ruby/core/module/method_defined_spec.rb4
-rw-r--r--spec/ruby/core/module/module_function_spec.rb10
-rw-r--r--spec/ruby/core/module/prepend_features_spec.rb4
-rw-r--r--spec/ruby/core/module/prepend_spec.rb10
-rw-r--r--spec/ruby/core/module/private_class_method_spec.rb20
-rw-r--r--spec/ruby/core/module/private_constant_spec.rb8
-rw-r--r--spec/ruby/core/module/private_method_defined_spec.rb10
-rw-r--r--spec/ruby/core/module/private_spec.rb6
-rw-r--r--spec/ruby/core/module/protected_method_defined_spec.rb10
-rw-r--r--spec/ruby/core/module/protected_spec.rb4
-rw-r--r--spec/ruby/core/module/public_class_method_spec.rb14
-rw-r--r--spec/ruby/core/module/public_constant_spec.rb2
-rw-r--r--spec/ruby/core/module/public_instance_method_spec.rb10
-rw-r--r--spec/ruby/core/module/public_method_defined_spec.rb10
-rw-r--r--spec/ruby/core/module/public_spec.rb2
-rw-r--r--spec/ruby/core/module/refine_spec.rb20
-rw-r--r--spec/ruby/core/module/remove_class_variable_spec.rb8
-rw-r--r--spec/ruby/core/module/remove_const_spec.rb26
-rw-r--r--spec/ruby/core/module/remove_method_spec.rb6
-rw-r--r--spec/ruby/core/module/shared/class_eval.rb14
-rw-r--r--spec/ruby/core/module/shared/class_exec.rb4
-rw-r--r--spec/ruby/core/module/undef_method_spec.rb20
-rw-r--r--spec/ruby/core/module/using_spec.rb10
47 files changed, 306 insertions, 284 deletions
diff --git a/spec/ruby/core/module/alias_method_spec.rb b/spec/ruby/core/module/alias_method_spec.rb
index 8a2ddafda1..b14f5430a8 100644
--- a/spec/ruby/core/module/alias_method_spec.rb
+++ b/spec/ruby/core/module/alias_method_spec.rb
@@ -28,12 +28,12 @@ describe "Module#alias_method" do
it "retains method visibility" do
@class.make_alias :private_ichi, :private_one
- lambda { @object.private_one }.should raise_error(NameError)
- lambda { @object.private_ichi }.should raise_error(NameError)
+ -> { @object.private_one }.should raise_error(NameError)
+ -> { @object.private_ichi }.should raise_error(NameError)
@class.make_alias :public_ichi, :public_one
@object.public_ichi.should == @object.public_one
@class.make_alias :protected_ichi, :protected_one
- lambda { @object.protected_ichi }.should raise_error(NameError)
+ -> { @object.protected_ichi }.should raise_error(NameError)
end
it "handles aliasing a stub that changes visibility" do
@@ -43,7 +43,7 @@ describe "Module#alias_method" do
end
it "fails if origin method not found" do
- lambda { @class.make_alias :ni, :san }.should raise_error(NameError) { |e|
+ -> { @class.make_alias :ni, :san }.should raise_error(NameError) { |e|
# a NameError and not a NoMethodError
e.class.should == NameError
}
@@ -51,7 +51,7 @@ describe "Module#alias_method" do
it "raises #{frozen_error_class} if frozen" do
@class.freeze
- lambda { @class.make_alias :uno, :public_one }.should raise_error(frozen_error_class)
+ -> { @class.make_alias :uno, :public_one }.should raise_error(frozen_error_class)
end
it "converts the names using #to_str" do
@@ -66,12 +66,12 @@ describe "Module#alias_method" do
end
it "raises a TypeError when the given name can't be converted using to_str" do
- lambda { @class.make_alias mock('x'), :public_one }.should raise_error(TypeError)
+ -> { @class.make_alias mock('x'), :public_one }.should raise_error(TypeError)
end
ruby_version_is ''...'2.5' do
it "is a private method" do
- lambda { @class.alias_method :ichi, :public_one }.should raise_error(NoMethodError)
+ -> { @class.alias_method :ichi, :public_one }.should raise_error(NoMethodError)
end
end
ruby_version_is '2.5' do
@@ -90,7 +90,7 @@ describe "Module#alias_method" do
it "works on private module methods in a module that has been reopened" do
ModuleSpecs::ReopeningModule.foo.should == true
- lambda { ModuleSpecs::ReopeningModule.foo2 }.should_not raise_error(NoMethodError)
+ -> { ModuleSpecs::ReopeningModule.foo2 }.should_not raise_error(NoMethodError)
end
it "accesses a method defined on Object from Kernel" do
diff --git a/spec/ruby/core/module/append_features_spec.rb b/spec/ruby/core/module/append_features_spec.rb
index c5dd64aa6f..584aa11dfa 100644
--- a/spec/ruby/core/module/append_features_spec.rb
+++ b/spec/ruby/core/module/append_features_spec.rb
@@ -12,7 +12,7 @@ describe "Module#append_features" do
end
it "raises a TypeError if calling after rebinded to Class" do
- lambda {
+ -> {
Module.instance_method(:append_features).bind(Class.new).call Module.new
}.should raise_error(TypeError)
end
@@ -37,11 +37,11 @@ describe "Module#append_features" do
end
it "raises an ArgumentError on a cyclic include" do
- lambda {
+ -> {
ModuleSpecs::CyclicAppendA.send(:append_features, ModuleSpecs::CyclicAppendA)
}.should raise_error(ArgumentError)
- lambda {
+ -> {
ModuleSpecs::CyclicAppendB.send(:append_features, ModuleSpecs::CyclicAppendA)
}.should raise_error(ArgumentError)
@@ -66,7 +66,7 @@ describe "Module#append_features" do
end
it "raises a #{frozen_error_class} before appending self" do
- lambda { @receiver.send(:append_features, @other) }.should raise_error(frozen_error_class)
+ -> { @receiver.send(:append_features, @other) }.should raise_error(frozen_error_class)
@other.ancestors.should_not include(@receiver)
end
end
diff --git a/spec/ruby/core/module/attr_accessor_spec.rb b/spec/ruby/core/module/attr_accessor_spec.rb
index b5e3d72524..ce95ccd487 100644
--- a/spec/ruby/core/module/attr_accessor_spec.rb
+++ b/spec/ruby/core/module/attr_accessor_spec.rb
@@ -33,7 +33,7 @@ describe "Module#attr_accessor" do
attr_accessor :spec_attr_accessor
end
- lambda { true.spec_attr_accessor = "a" }.should raise_error(RuntimeError)
+ -> { true.spec_attr_accessor = "a" }.should raise_error(RuntimeError)
end
it "converts non string/symbol/fixnum names to strings using to_str" do
@@ -48,9 +48,9 @@ describe "Module#attr_accessor" do
it "raises a TypeError when the given names can't be converted to strings using to_str" do
o = mock('o')
- lambda { Class.new { attr_accessor o } }.should raise_error(TypeError)
+ -> { Class.new { attr_accessor o } }.should raise_error(TypeError)
(o = mock('123')).should_receive(:to_str).and_return(123)
- lambda { Class.new { attr_accessor o } }.should raise_error(TypeError)
+ -> { Class.new { attr_accessor o } }.should raise_error(TypeError)
end
it "applies current visibility to methods created" do
@@ -59,8 +59,8 @@ describe "Module#attr_accessor" do
attr_accessor :foo
end
- lambda { c.new.foo }.should raise_error(NoMethodError)
- lambda { c.new.foo=1 }.should raise_error(NoMethodError)
+ -> { c.new.foo }.should raise_error(NoMethodError)
+ -> { c.new.foo=1 }.should raise_error(NoMethodError)
end
ruby_version_is ''...'2.5' do
diff --git a/spec/ruby/core/module/attr_reader_spec.rb b/spec/ruby/core/module/attr_reader_spec.rb
index f537b5f1c6..082bc03b60 100644
--- a/spec/ruby/core/module/attr_reader_spec.rb
+++ b/spec/ruby/core/module/attr_reader_spec.rb
@@ -29,7 +29,7 @@ describe "Module#attr_reader" do
attr_reader :spec_attr_reader
end
- lambda { true.instance_variable_set("@spec_attr_reader", "a") }.should raise_error(RuntimeError)
+ -> { true.instance_variable_set("@spec_attr_reader", "a") }.should raise_error(RuntimeError)
end
it "converts non string/symbol/fixnum names to strings using to_str" do
@@ -44,9 +44,9 @@ describe "Module#attr_reader" do
it "raises a TypeError when the given names can't be converted to strings using to_str" do
o = mock('o')
- lambda { Class.new { attr_reader o } }.should raise_error(TypeError)
+ -> { Class.new { attr_reader o } }.should raise_error(TypeError)
(o = mock('123')).should_receive(:to_str).and_return(123)
- lambda { Class.new { attr_reader o } }.should raise_error(TypeError)
+ -> { Class.new { attr_reader o } }.should raise_error(TypeError)
end
it "applies current visibility to methods created" do
@@ -55,7 +55,7 @@ describe "Module#attr_reader" do
attr_reader :foo
end
- lambda { c.new.foo }.should raise_error(NoMethodError)
+ -> { c.new.foo }.should raise_error(NoMethodError)
end
ruby_version_is ''...'2.5' do
diff --git a/spec/ruby/core/module/attr_spec.rb b/spec/ruby/core/module/attr_spec.rb
index 16680730d5..20316a3d39 100644
--- a/spec/ruby/core/module/attr_spec.rb
+++ b/spec/ruby/core/module/attr_spec.rb
@@ -89,8 +89,8 @@ describe "Module#attr" do
attr :foo, true
end
- lambda { c.new.foo }.should raise_error(NoMethodError)
- lambda { c.new.foo=1 }.should raise_error(NoMethodError)
+ -> { c.new.foo }.should raise_error(NoMethodError)
+ -> { c.new.foo=1 }.should raise_error(NoMethodError)
end
it "creates a getter but no setter for all given attribute names" do
@@ -120,8 +120,8 @@ describe "Module#attr" do
attr :foo, :bar
end
- lambda { c.new.foo }.should raise_error(NoMethodError)
- lambda { c.new.bar }.should raise_error(NoMethodError)
+ -> { c.new.foo }.should raise_error(NoMethodError)
+ -> { c.new.bar }.should raise_error(NoMethodError)
end
it "converts non string/symbol/fixnum names to strings using to_str" do
@@ -131,13 +131,13 @@ describe "Module#attr" do
it "raises a TypeError when the given names can't be converted to strings using to_str" do
o = mock('o')
- lambda { Class.new { attr o } }.should raise_error(TypeError)
+ -> { Class.new { attr o } }.should raise_error(TypeError)
(o = mock('123')).should_receive(:to_str).and_return(123)
- lambda { Class.new { attr o } }.should raise_error(TypeError)
+ -> { Class.new { attr o } }.should raise_error(TypeError)
end
it "with a boolean argument emits a warning when $VERBOSE is true" do
- lambda {
+ -> {
Class.new { attr :foo, true }
}.should complain(/boolean argument is obsoleted/, verbose: true)
end
diff --git a/spec/ruby/core/module/attr_writer_spec.rb b/spec/ruby/core/module/attr_writer_spec.rb
index ea77f81f28..3b110cecf7 100644
--- a/spec/ruby/core/module/attr_writer_spec.rb
+++ b/spec/ruby/core/module/attr_writer_spec.rb
@@ -29,7 +29,7 @@ describe "Module#attr_writer" do
attr_writer :spec_attr_writer
end
- lambda { true.spec_attr_writer = "a" }.should raise_error(RuntimeError)
+ -> { true.spec_attr_writer = "a" }.should raise_error(RuntimeError)
end
it "converts non string/symbol/fixnum names to strings using to_str" do
@@ -44,9 +44,9 @@ describe "Module#attr_writer" do
it "raises a TypeError when the given names can't be converted to strings using to_str" do
o = mock('test1')
- lambda { Class.new { attr_writer o } }.should raise_error(TypeError)
+ -> { Class.new { attr_writer o } }.should raise_error(TypeError)
(o = mock('123')).should_receive(:to_str).and_return(123)
- lambda { Class.new { attr_writer o } }.should raise_error(TypeError)
+ -> { Class.new { attr_writer o } }.should raise_error(TypeError)
end
it "applies current visibility to methods created" do
@@ -55,7 +55,7 @@ describe "Module#attr_writer" do
attr_writer :foo
end
- lambda { c.new.foo=1 }.should raise_error(NoMethodError)
+ -> { c.new.foo=1 }.should raise_error(NoMethodError)
end
ruby_version_is ''...'2.5' do
diff --git a/spec/ruby/core/module/autoload_spec.rb b/spec/ruby/core/module/autoload_spec.rb
index ca4c63838c..6a1efa1ec2 100644
--- a/spec/ruby/core/module/autoload_spec.rb
+++ b/spec/ruby/core/module/autoload_spec.rb
@@ -189,7 +189,7 @@ describe "Module#autoload" do
ModuleSpecs::Autoload.autoload :NotThere, filename
ModuleSpecs::Autoload.autoload?(:NotThere).should == filename
- lambda {
+ -> {
require filename
}.should raise_error(LoadError)
@@ -385,13 +385,13 @@ describe "Module#autoload" do
ModuleSpecs::Autoload.should have_constant(:Fail)
ModuleSpecs::Autoload.autoload?(:Fail).should == @non_existent
- lambda { ModuleSpecs::Autoload::Fail }.should raise_error(LoadError)
+ -> { ModuleSpecs::Autoload::Fail }.should raise_error(LoadError)
ModuleSpecs::Autoload.should have_constant(:Fail)
ModuleSpecs::Autoload.const_defined?(:Fail).should == true
ModuleSpecs::Autoload.autoload?(:Fail).should == @non_existent
- lambda { ModuleSpecs::Autoload::Fail }.should raise_error(LoadError)
+ -> { ModuleSpecs::Autoload::Fail }.should raise_error(LoadError)
end
it "does not remove the constant from Module#constants if load raises a RuntimeError and keeps it as an autoload" do
@@ -403,14 +403,14 @@ describe "Module#autoload" do
ModuleSpecs::Autoload.should have_constant(:Raise)
ModuleSpecs::Autoload.autoload?(:Raise).should == path
- lambda { ModuleSpecs::Autoload::Raise }.should raise_error(RuntimeError)
+ -> { ModuleSpecs::Autoload::Raise }.should raise_error(RuntimeError)
ScratchPad.recorded.should == [:raise]
ModuleSpecs::Autoload.should have_constant(:Raise)
ModuleSpecs::Autoload.const_defined?(:Raise).should == true
ModuleSpecs::Autoload.autoload?(:Raise).should == path
- lambda { ModuleSpecs::Autoload::Raise }.should raise_error(RuntimeError)
+ -> { ModuleSpecs::Autoload::Raise }.should raise_error(RuntimeError)
ScratchPad.recorded.should == [:raise, :raise]
end
@@ -423,7 +423,7 @@ describe "Module#autoload" do
ModuleSpecs::Autoload.should have_constant(:O)
ModuleSpecs::Autoload.autoload?(:O).should == path
- lambda { ModuleSpecs::Autoload::O }.should raise_error(NameError)
+ -> { ModuleSpecs::Autoload::O }.should raise_error(NameError)
ModuleSpecs::Autoload.should have_constant(:O)
ModuleSpecs::Autoload.const_defined?(:O).should == false
@@ -659,19 +659,19 @@ describe "Module#autoload" do
end
it "raises an ArgumentError when an empty filename is given" do
- lambda { ModuleSpecs.autoload :A, "" }.should raise_error(ArgumentError)
+ -> { ModuleSpecs.autoload :A, "" }.should raise_error(ArgumentError)
end
it "raises a NameError when the constant name starts with a lower case letter" do
- lambda { ModuleSpecs.autoload "a", @non_existent }.should raise_error(NameError)
+ -> { ModuleSpecs.autoload "a", @non_existent }.should raise_error(NameError)
end
it "raises a NameError when the constant name starts with a number" do
- lambda { ModuleSpecs.autoload "1two", @non_existent }.should raise_error(NameError)
+ -> { ModuleSpecs.autoload "1two", @non_existent }.should raise_error(NameError)
end
it "raises a NameError when the constant name has a space in it" do
- lambda { ModuleSpecs.autoload "a name", @non_existent }.should raise_error(NameError)
+ -> { ModuleSpecs.autoload "a name", @non_existent }.should raise_error(NameError)
end
it "shares the autoload request across dup'ed copies of modules" do
@@ -679,7 +679,7 @@ describe "Module#autoload" do
@remove << :S
filename = fixture(__FILE__, "autoload_t.rb")
mod1 = Module.new { autoload :T, filename }
- lambda {
+ -> {
ModuleSpecs::Autoload::S = mod1
}.should complain(/already initialized constant/)
mod2 = mod1.dup
@@ -688,7 +688,7 @@ describe "Module#autoload" do
mod2.autoload?(:T).should == filename
mod1::T.should == :autoload_t
- lambda { mod2::T }.should raise_error(NameError)
+ -> { mod2::T }.should raise_error(NameError)
end
it "raises a TypeError if opening a class with a different superclass than the class defined in the autoload file" do
@@ -696,7 +696,7 @@ describe "Module#autoload" do
class ModuleSpecs::Autoload::ZZ
end
- lambda do
+ -> do
class ModuleSpecs::Autoload::Z < ModuleSpecs::Autoload::ZZ
end
end.should raise_error(TypeError)
@@ -705,20 +705,20 @@ describe "Module#autoload" do
it "raises a TypeError if not passed a String or object responding to #to_path for the filename" do
name = mock("autoload_name.rb")
- lambda { ModuleSpecs::Autoload.autoload :Str, name }.should raise_error(TypeError)
+ -> { ModuleSpecs::Autoload.autoload :Str, name }.should raise_error(TypeError)
end
it "calls #to_path on non-String filename arguments" do
name = mock("autoload_name.rb")
name.should_receive(:to_path).and_return("autoload_name.rb")
- lambda { ModuleSpecs::Autoload.autoload :Str, name }.should_not raise_error
+ -> { ModuleSpecs::Autoload.autoload :Str, name }.should_not raise_error
end
describe "on a frozen module" do
it "raises a #{frozen_error_class} before setting the name" do
frozen_module = Module.new.freeze
- lambda { frozen_module.autoload :Foo, @non_existent }.should raise_error(frozen_error_class)
+ -> { frozen_module.autoload :Foo, @non_existent }.should raise_error(frozen_error_class)
frozen_module.should_not have_constant(:Foo)
end
end
diff --git a/spec/ruby/core/module/class_variable_defined_spec.rb b/spec/ruby/core/module/class_variable_defined_spec.rb
index 25fd73a136..f867d383c3 100644
--- a/spec/ruby/core/module/class_variable_defined_spec.rb
+++ b/spec/ruby/core/module/class_variable_defined_spec.rb
@@ -42,11 +42,11 @@ describe "Module#class_variable_defined?" do
it "raises a NameError when the given name is not allowed" do
c = Class.new
- lambda {
+ -> {
c.class_variable_defined?(:invalid_name)
}.should raise_error(NameError)
- lambda {
+ -> {
c.class_variable_defined?("@invalid_name")
}.should raise_error(NameError)
end
@@ -60,12 +60,12 @@ describe "Module#class_variable_defined?" do
it "raises a TypeError when the given names can't be converted to strings using to_str" do
c = Class.new { class_variable_set :@@class_var, "test" }
o = mock('123')
- lambda {
+ -> {
c.class_variable_defined?(o)
}.should raise_error(TypeError)
o.should_receive(:to_str).and_return(123)
- lambda {
+ -> {
c.class_variable_defined?(o)
}.should raise_error(TypeError)
end
diff --git a/spec/ruby/core/module/class_variable_get_spec.rb b/spec/ruby/core/module/class_variable_get_spec.rb
index 7619c135ab..79d22a506b 100644
--- a/spec/ruby/core/module/class_variable_get_spec.rb
+++ b/spec/ruby/core/module/class_variable_get_spec.rb
@@ -15,14 +15,14 @@ describe "Module#class_variable_get" do
it "raises a NameError for a class variable named '@@'" do
c = Class.new
- lambda { c.send(:class_variable_get, "@@") }.should raise_error(NameError)
- lambda { c.send(:class_variable_get, :"@@") }.should raise_error(NameError)
+ -> { c.send(:class_variable_get, "@@") }.should raise_error(NameError)
+ -> { c.send(:class_variable_get, :"@@") }.should raise_error(NameError)
end
it "raises a NameError for a class variables with the given name defined in an extended module" do
c = Class.new
c.extend ModuleSpecs::MVars
- lambda {
+ -> {
c.send(:class_variable_get, "@@mvar")
}.should raise_error(NameError)
end
@@ -49,15 +49,15 @@ describe "Module#class_variable_get" do
it "raises a NameError when an uninitialized class variable is accessed" do
c = Class.new
[:@@no_class_var, "@@no_class_var"].each do |cvar|
- lambda { c.send(:class_variable_get, cvar) }.should raise_error(NameError)
+ -> { c.send(:class_variable_get, cvar) }.should raise_error(NameError)
end
end
it "raises a NameError when the given name is not allowed" do
c = Class.new
- lambda { c.send(:class_variable_get, :invalid_name) }.should raise_error(NameError)
- lambda { c.send(:class_variable_get, "@invalid_name") }.should raise_error(NameError)
+ -> { c.send(:class_variable_get, :invalid_name) }.should raise_error(NameError)
+ -> { c.send(:class_variable_get, "@invalid_name") }.should raise_error(NameError)
end
it "converts a non string/symbol/fixnum name to string using to_str" do
@@ -69,8 +69,8 @@ describe "Module#class_variable_get" do
it "raises a TypeError when the given names can't be converted to strings using to_str" do
c = Class.new { class_variable_set :@@class_var, "test" }
o = mock('123')
- lambda { c.send(:class_variable_get, o) }.should raise_error(TypeError)
+ -> { c.send(:class_variable_get, o) }.should raise_error(TypeError)
o.should_receive(:to_str).and_return(123)
- lambda { c.send(:class_variable_get, o) }.should raise_error(TypeError)
+ -> { c.send(:class_variable_get, o) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/module/class_variable_set_spec.rb b/spec/ruby/core/module/class_variable_set_spec.rb
index dcb5da87b6..204bbaf75e 100644
--- a/spec/ruby/core/module/class_variable_set_spec.rb
+++ b/spec/ruby/core/module/class_variable_set_spec.rb
@@ -26,10 +26,10 @@ describe "Module#class_variable_set" do
end
it "raises a #{frozen_error_class} when self is frozen" do
- lambda {
+ -> {
Class.new.freeze.send(:class_variable_set, :@@test, "test")
}.should raise_error(frozen_error_class)
- lambda {
+ -> {
Module.new.freeze.send(:class_variable_set, :@@test, "test")
}.should raise_error(frozen_error_class)
end
@@ -37,10 +37,10 @@ describe "Module#class_variable_set" do
it "raises a NameError when the given name is not allowed" do
c = Class.new
- lambda {
+ -> {
c.send(:class_variable_set, :invalid_name, "test")
}.should raise_error(NameError)
- lambda {
+ -> {
c.send(:class_variable_set, "@invalid_name", "test")
}.should raise_error(NameError)
end
@@ -55,8 +55,8 @@ describe "Module#class_variable_set" do
it "raises a TypeError when the given names can't be converted to strings using to_str" do
c = Class.new { class_variable_set :@@class_var, "test" }
o = mock('123')
- lambda { c.send(:class_variable_set, o, "test") }.should raise_error(TypeError)
+ -> { c.send(:class_variable_set, o, "test") }.should raise_error(TypeError)
o.should_receive(:to_str).and_return(123)
- lambda { c.send(:class_variable_set, o, "test") }.should raise_error(TypeError)
+ -> { c.send(:class_variable_set, o, "test") }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/module/const_defined_spec.rb b/spec/ruby/core/module/const_defined_spec.rb
index cb1674c7e7..0673adca3d 100644
--- a/spec/ruby/core/module/const_defined_spec.rb
+++ b/spec/ruby/core/module/const_defined_spec.rb
@@ -105,19 +105,19 @@ describe "Module#const_defined?" do
end
it "raises a NameError if the name does not start with a capital letter" do
- lambda { ConstantSpecs.const_defined? "name" }.should raise_error(NameError)
+ -> { ConstantSpecs.const_defined? "name" }.should raise_error(NameError)
end
it "raises a NameError if the name starts with '_'" do
- lambda { ConstantSpecs.const_defined? "__CONSTX__" }.should raise_error(NameError)
+ -> { ConstantSpecs.const_defined? "__CONSTX__" }.should raise_error(NameError)
end
it "raises a NameError if the name starts with '@'" do
- lambda { ConstantSpecs.const_defined? "@Name" }.should raise_error(NameError)
+ -> { ConstantSpecs.const_defined? "@Name" }.should raise_error(NameError)
end
it "raises a NameError if the name starts with '!'" do
- lambda { ConstantSpecs.const_defined? "!Name" }.should raise_error(NameError)
+ -> { ConstantSpecs.const_defined? "!Name" }.should raise_error(NameError)
end
it "returns true or false for the nested name" do
@@ -130,15 +130,15 @@ describe "Module#const_defined?" do
it "raises a NameError if the name contains non-alphabetic characters except '_'" do
ConstantSpecs.const_defined?("CS_CONSTX").should == false
- lambda { ConstantSpecs.const_defined? "Name=" }.should raise_error(NameError)
- lambda { ConstantSpecs.const_defined? "Name?" }.should raise_error(NameError)
+ -> { ConstantSpecs.const_defined? "Name=" }.should raise_error(NameError)
+ -> { ConstantSpecs.const_defined? "Name?" }.should raise_error(NameError)
end
it "raises a TypeError if conversion to a String by calling #to_str fails" do
name = mock('123')
- lambda { ConstantSpecs.const_defined? name }.should raise_error(TypeError)
+ -> { ConstantSpecs.const_defined? name }.should raise_error(TypeError)
name.should_receive(:to_str).and_return(123)
- lambda { ConstantSpecs.const_defined? name }.should raise_error(TypeError)
+ -> { ConstantSpecs.const_defined? name }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/module/const_get_spec.rb b/spec/ruby/core/module/const_get_spec.rb
index d125c35762..0a6702903f 100644
--- a/spec/ruby/core/module/const_get_spec.rb
+++ b/spec/ruby/core/module/const_get_spec.rb
@@ -9,28 +9,28 @@ describe "Module#const_get" do
end
it "raises a NameError if no constant is defined in the search path" do
- lambda { ConstantSpecs.const_get :CS_CONSTX }.should raise_error(NameError)
+ -> { ConstantSpecs.const_get :CS_CONSTX }.should raise_error(NameError)
end
it "raises a NameError with the not found constant symbol" do
- error_inspection = lambda { |e| e.name.should == :CS_CONSTX }
- lambda { ConstantSpecs.const_get :CS_CONSTX }.should raise_error(NameError, &error_inspection)
+ error_inspection = -> e { e.name.should == :CS_CONSTX }
+ -> { ConstantSpecs.const_get :CS_CONSTX }.should raise_error(NameError, &error_inspection)
end
it "raises a NameError if the name does not start with a capital letter" do
- lambda { ConstantSpecs.const_get "name" }.should raise_error(NameError)
+ -> { ConstantSpecs.const_get "name" }.should raise_error(NameError)
end
it "raises a NameError if the name starts with a non-alphabetic character" do
- lambda { ConstantSpecs.const_get "__CONSTX__" }.should raise_error(NameError)
- lambda { ConstantSpecs.const_get "@CS_CONST1" }.should raise_error(NameError)
- lambda { ConstantSpecs.const_get "!CS_CONST1" }.should raise_error(NameError)
+ -> { ConstantSpecs.const_get "__CONSTX__" }.should raise_error(NameError)
+ -> { ConstantSpecs.const_get "@CS_CONST1" }.should raise_error(NameError)
+ -> { ConstantSpecs.const_get "!CS_CONST1" }.should raise_error(NameError)
end
it "raises a NameError if the name contains non-alphabetic characters except '_'" do
Object.const_get("CS_CONST1").should == :const1
- lambda { ConstantSpecs.const_get "CS_CONST1=" }.should raise_error(NameError)
- lambda { ConstantSpecs.const_get "CS_CONST1?" }.should raise_error(NameError)
+ -> { ConstantSpecs.const_get "CS_CONST1=" }.should raise_error(NameError)
+ -> { ConstantSpecs.const_get "CS_CONST1?" }.should raise_error(NameError)
end
it "calls #to_str to convert the given name to a String" do
@@ -41,10 +41,10 @@ describe "Module#const_get" do
it "raises a TypeError if conversion to a String by calling #to_str fails" do
name = mock('123')
- lambda { ConstantSpecs.const_get(name) }.should raise_error(TypeError)
+ -> { ConstantSpecs.const_get(name) }.should raise_error(TypeError)
name.should_receive(:to_str).and_return(123)
- lambda { ConstantSpecs.const_get(name) }.should raise_error(TypeError)
+ -> { ConstantSpecs.const_get(name) }.should raise_error(TypeError)
end
it "calls #const_missing on the receiver if unable to locate the constant" do
@@ -53,21 +53,21 @@ describe "Module#const_get" do
end
it "does not search the singleton class of a Class or Module" do
- lambda do
+ -> do
ConstantSpecs::ContainerA::ChildA.const_get(:CS_CONST14)
end.should raise_error(NameError)
- lambda { ConstantSpecs.const_get(:CS_CONST14) }.should raise_error(NameError)
+ -> { ConstantSpecs.const_get(:CS_CONST14) }.should raise_error(NameError)
end
it "does not search the containing scope" do
ConstantSpecs::ContainerA::ChildA.const_get(:CS_CONST20).should == :const20_2
- lambda do
+ -> do
ConstantSpecs::ContainerA::ChildA.const_get(:CS_CONST5)
end.should raise_error(NameError)
end
it "raises a NameError if the constant is defined in the receiver's superclass and the inherit flag is false" do
- lambda do
+ -> do
ConstantSpecs::ContainerA::ChildA.const_get(:CS_CONST4, false)
end.should raise_error(NameError)
end
@@ -77,13 +77,13 @@ describe "Module#const_get" do
end
it "raises a NameError when the receiver is a Module, the constant is defined at toplevel and the inherit flag is false" do
- lambda do
+ -> do
ConstantSpecs::ModuleA.const_get(:CS_CONST1, false)
end.should raise_error(NameError)
end
it "raises a NameError when the receiver is a Class, the constant is defined at toplevel and the inherit flag is false" do
- lambda do
+ -> do
ConstantSpecs::ContainerA::ChildA.const_get(:CS_CONST1, false)
end.should raise_error(NameError)
end
@@ -97,19 +97,19 @@ describe "Module#const_get" do
end
it "raises a NameError if the name includes two successive scope separators" do
- lambda { ConstantSpecs.const_get("ClassA::::CS_CONST10") }.should raise_error(NameError)
+ -> { ConstantSpecs.const_get("ClassA::::CS_CONST10") }.should raise_error(NameError)
end
it "raises a NameError if only '::' is passed" do
- lambda { ConstantSpecs.const_get("::") }.should raise_error(NameError)
+ -> { ConstantSpecs.const_get("::") }.should raise_error(NameError)
end
it "raises a NameError if a Symbol has a toplevel scope qualifier" do
- lambda { ConstantSpecs.const_get(:'::CS_CONST1') }.should raise_error(NameError)
+ -> { ConstantSpecs.const_get(:'::CS_CONST1') }.should raise_error(NameError)
end
it "raises a NameError if a Symbol is a scoped constant name" do
- lambda { ConstantSpecs.const_get(:'ClassA::CS_CONST10') }.should raise_error(NameError)
+ -> { ConstantSpecs.const_get(:'ClassA::CS_CONST10') }.should raise_error(NameError)
end
it "does read private constants" do
@@ -220,7 +220,7 @@ describe "Module#const_get" do
ConstantSpecs::ClassB::CS_CONST309 = :const309_1
ConstantSpecs::ClassB.const_get(:CS_CONST309).should == :const309_1
- lambda {
+ -> {
ConstantSpecs::ClassB::CS_CONST309 = :const309_2
}.should complain(/already initialized constant/)
ConstantSpecs::ClassB.const_get(:CS_CONST309).should == :const309_2
diff --git a/spec/ruby/core/module/const_missing_spec.rb b/spec/ruby/core/module/const_missing_spec.rb
index 930fe63f8b..742218281c 100644
--- a/spec/ruby/core/module/const_missing_spec.rb
+++ b/spec/ruby/core/module/const_missing_spec.rb
@@ -11,7 +11,7 @@ describe "Module#const_missing" do
end
it "raises NameError and includes the name of the value that wasn't found" do
- lambda {
+ -> {
ConstantSpecs.const_missing("HelloMissing")
}.should raise_error(NameError, /ConstantSpecs::HelloMissing/)
end
diff --git a/spec/ruby/core/module/const_set_spec.rb b/spec/ruby/core/module/const_set_spec.rb
index 25d22ffaba..1b8b86dd04 100644
--- a/spec/ruby/core/module/const_set_spec.rb
+++ b/spec/ruby/core/module/const_set_spec.rb
@@ -41,20 +41,20 @@ describe "Module#const_set" do
end
it "raises a NameError if the name does not start with a capital letter" do
- lambda { ConstantSpecs.const_set "name", 1 }.should raise_error(NameError)
+ -> { ConstantSpecs.const_set "name", 1 }.should raise_error(NameError)
end
it "raises a NameError if the name starts with a non-alphabetic character" do
- lambda { ConstantSpecs.const_set "__CONSTX__", 1 }.should raise_error(NameError)
- lambda { ConstantSpecs.const_set "@Name", 1 }.should raise_error(NameError)
- lambda { ConstantSpecs.const_set "!Name", 1 }.should raise_error(NameError)
- lambda { ConstantSpecs.const_set "::Name", 1 }.should raise_error(NameError)
+ -> { ConstantSpecs.const_set "__CONSTX__", 1 }.should raise_error(NameError)
+ -> { ConstantSpecs.const_set "@Name", 1 }.should raise_error(NameError)
+ -> { ConstantSpecs.const_set "!Name", 1 }.should raise_error(NameError)
+ -> { ConstantSpecs.const_set "::Name", 1 }.should raise_error(NameError)
end
it "raises a NameError if the name contains non-alphabetic characters except '_'" do
ConstantSpecs.const_set("CS_CONST404", :const404).should == :const404
- lambda { ConstantSpecs.const_set "Name=", 1 }.should raise_error(NameError)
- lambda { ConstantSpecs.const_set "Name?", 1 }.should raise_error(NameError)
+ -> { ConstantSpecs.const_set "Name=", 1 }.should raise_error(NameError)
+ -> { ConstantSpecs.const_set "Name?", 1 }.should raise_error(NameError)
end
it "calls #to_str to convert the given name to a String" do
@@ -66,10 +66,10 @@ describe "Module#const_set" do
it "raises a TypeError if conversion to a String by calling #to_str fails" do
name = mock('123')
- lambda { ConstantSpecs.const_set name, 1 }.should raise_error(TypeError)
+ -> { ConstantSpecs.const_set name, 1 }.should raise_error(TypeError)
name.should_receive(:to_str).and_return(123)
- lambda { ConstantSpecs.const_set name, 1 }.should raise_error(TypeError)
+ -> { ConstantSpecs.const_set name, 1 }.should raise_error(TypeError)
end
describe "when overwriting an existing constant" do
@@ -126,7 +126,7 @@ describe "Module#const_set" do
end
it "raises a #{frozen_error_class} before setting the name" do
- lambda { @frozen.const_set @name, nil }.should raise_error(frozen_error_class)
+ -> { @frozen.const_set @name, nil }.should raise_error(frozen_error_class)
@frozen.should_not have_constant(@name)
end
end
diff --git a/spec/ruby/core/module/define_method_spec.rb b/spec/ruby/core/module/define_method_spec.rb
index 3f35c051a1..29394e5b92 100644
--- a/spec/ruby/core/module/define_method_spec.rb
+++ b/spec/ruby/core/module/define_method_spec.rb
@@ -12,7 +12,7 @@ describe "passed { |a, b = 1| } creates a method that" do
end
it "raises an ArgumentError when passed zero arguments" do
- lambda { @klass.new.m }.should raise_error(ArgumentError)
+ -> { @klass.new.m }.should raise_error(ArgumentError)
end
it "has a default value for b when passed one argument" do
@@ -24,7 +24,7 @@ describe "passed { |a, b = 1| } creates a method that" do
end
it "raises an ArgumentError when passed three arguments" do
- lambda { @klass.new.m(1, 2, 3) }.should raise_error(ArgumentError)
+ -> { @klass.new.m(1, 2, 3) }.should raise_error(ArgumentError)
end
end
@@ -83,7 +83,7 @@ describe "Module#define_method when given an UnboundMethod" do
define_method :piggy, instance_method(:ziggy)
end
- lambda { foo.new.ziggy }.should raise_error(NoMethodError)
+ -> { foo.new.ziggy }.should raise_error(NoMethodError)
foo.new.piggy.should == 'piggy'
end
end
@@ -194,7 +194,7 @@ describe "Module#define_method" do
it "defines a new method with the given name and the given block as body in self" do
class DefineMethodSpecClass
define_method(:block_test1) { self }
- define_method(:block_test2, &lambda { self })
+ define_method(:block_test2, &-> { self })
end
o = DefineMethodSpecClass.new
@@ -203,21 +203,21 @@ describe "Module#define_method" do
end
it "raises a TypeError when the given method is no Method/Proc" do
- lambda {
+ -> {
Class.new { define_method(:test, "self") }
}.should raise_error(TypeError)
- lambda {
+ -> {
Class.new { define_method(:test, 1234) }
}.should raise_error(TypeError)
- lambda {
+ -> {
Class.new { define_method(:test, nil) }
}.should raise_error(TypeError)
end
it "raises an ArgumentError when no block is given" do
- lambda {
+ -> {
Class.new { define_method(:test) }
}.should raise_error(ArgumentError)
end
@@ -230,7 +230,7 @@ describe "Module#define_method" do
end
end
- lambda {
+ -> {
o.define(:foo) { raise "not used" }
}.should raise_error(ArgumentError)
end
@@ -242,11 +242,11 @@ describe "Module#define_method" do
end
obj = DefineMethodSpecClass.new
- lambda { obj.proc_style_test :arg }.should raise_error(ArgumentError)
+ -> { obj.proc_style_test :arg }.should raise_error(ArgumentError)
end
it "raises a #{frozen_error_class} if frozen" do
- lambda {
+ -> {
Class.new { freeze; define_method(:foo) {} }
}.should raise_error(frozen_error_class)
end
@@ -267,7 +267,7 @@ describe "Module#define_method" do
c = klass.new
c.data = :bar
c.other_inspect.should == "data is bar"
- lambda{o.other_inspect}.should raise_error(NoMethodError)
+ ->{o.other_inspect}.should raise_error(NoMethodError)
end
it "raises a TypeError when a Method from a singleton class is defined on another class" do
@@ -279,9 +279,9 @@ describe "Module#define_method" do
end
m = c.method(:foo)
- lambda {
+ -> {
Class.new { define_method :bar, m }
- }.should raise_error(TypeError)
+ }.should raise_error(TypeError, /can't bind singleton method to a different class/)
end
it "raises a TypeError when a Method from one class is defined on an unrelated class" do
@@ -291,7 +291,7 @@ describe "Module#define_method" do
end
m = c.new.method(:foo)
- lambda {
+ -> {
Class.new { define_method :bar, m }
}.should raise_error(TypeError)
end
@@ -305,7 +305,7 @@ describe "Module#define_method" do
o = DefineMethodSpecClass.new
DefineMethodSpecClass.send(:undef_method, :accessor_method)
- lambda { o.accessor_method }.should raise_error(NoMethodError)
+ -> { o.accessor_method }.should raise_error(NoMethodError)
DefineMethodSpecClass.send(:define_method, :accessor_method, m)
@@ -396,20 +396,42 @@ describe "Module#define_method" do
klass.new.should respond_to(:bar)
end
+
+ it "allows an UnboundMethod of a Kernel method retrieved from Object to defined on a BasicObject subclass" do
+ klass = Class.new(BasicObject) do
+ define_method :instance_of?, ::Object.instance_method(:instance_of?)
+ end
+ klass.new.instance_of?(klass).should == true
+ end
+
it "raises a TypeError when an UnboundMethod from a child class is defined on a parent class" do
- lambda {
+ -> {
ParentClass = Class.new { define_method(:foo) { :bar } }
ChildClass = Class.new(ParentClass) { define_method(:foo) { :baz } }
ParentClass.send :define_method, :foo, ChildClass.instance_method(:foo)
- }.should raise_error(TypeError)
+ }.should raise_error(TypeError, /bind argument must be a subclass of ChildClass/)
end
it "raises a TypeError when an UnboundMethod from one class is defined on an unrelated class" do
- lambda {
+ -> {
DestinationClass = Class.new {
define_method :bar, ModuleSpecs::InstanceMeth.instance_method(:foo)
}
- }.should raise_error(TypeError)
+ }.should raise_error(TypeError, /bind argument must be a subclass of ModuleSpecs::InstanceMeth/)
+ end
+
+ it "raises a TypeError when an UnboundMethod from a singleton class is defined on another class" do
+ c = Class.new do
+ class << self
+ def foo
+ end
+ end
+ end
+ m = c.method(:foo).unbind
+
+ -> {
+ Class.new { define_method :bar, m }
+ }.should raise_error(TypeError, /can't bind singleton method to a different class/)
end
end
@@ -426,11 +448,11 @@ describe "Module#define_method" do
end
it "raises an ArgumentError when passed one argument" do
- lambda { @klass.new.m 1 }.should raise_error(ArgumentError)
+ -> { @klass.new.m 1 }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when passed two arguments" do
- lambda { @klass.new.m 1, 2 }.should raise_error(ArgumentError)
+ -> { @klass.new.m 1, 2 }.should raise_error(ArgumentError)
end
end
@@ -446,11 +468,11 @@ describe "Module#define_method" do
end
it "raises an ArgumentError when passed one argument" do
- lambda { @klass.new.m 1 }.should raise_error(ArgumentError)
+ -> { @klass.new.m 1 }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when passed two arguments" do
- lambda { @klass.new.m 1, 2 }.should raise_error(ArgumentError)
+ -> { @klass.new.m 1, 2 }.should raise_error(ArgumentError)
end
end
@@ -462,15 +484,15 @@ describe "Module#define_method" do
end
it "raises an ArgumentError when passed zero arguments" do
- lambda { @klass.new.m }.should raise_error(ArgumentError)
+ -> { @klass.new.m }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when passed zero arguments and a block" do
- lambda { @klass.new.m { :computed } }.should raise_error(ArgumentError)
+ -> { @klass.new.m { :computed } }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when passed two arguments" do
- lambda { @klass.new.m 1, 2 }.should raise_error(ArgumentError)
+ -> { @klass.new.m 1, 2 }.should raise_error(ArgumentError)
end
it "receives the value passed as the argument when passed one argument" do
@@ -507,7 +529,7 @@ describe "Module#define_method" do
end
it "raises an ArgumentError when passed zero arguments" do
- lambda { @klass.new.m }.should raise_error(ArgumentError)
+ -> { @klass.new.m }.should raise_error(ArgumentError)
end
it "returns the value computed by the block when passed one argument" do
@@ -535,19 +557,19 @@ describe "Module#define_method" do
end
it "raises an ArgumentError when passed zero arguments" do
- lambda { @klass.new.m }.should raise_error(ArgumentError)
+ -> { @klass.new.m }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when passed one argument" do
- lambda { @klass.new.m 1 }.should raise_error(ArgumentError)
+ -> { @klass.new.m 1 }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when passed one argument and a block" do
- lambda { @klass.new.m(1) { } }.should raise_error(ArgumentError)
+ -> { @klass.new.m(1) { } }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when passed three arguments" do
- lambda { @klass.new.m 1, 2, 3 }.should raise_error(ArgumentError)
+ -> { @klass.new.m 1, 2, 3 }.should raise_error(ArgumentError)
end
end
@@ -559,15 +581,15 @@ describe "Module#define_method" do
end
it "raises an ArgumentError when passed zero arguments" do
- lambda { @klass.new.m }.should raise_error(ArgumentError)
+ -> { @klass.new.m }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when passed one argument" do
- lambda { @klass.new.m 1 }.should raise_error(ArgumentError)
+ -> { @klass.new.m 1 }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when passed one argument and a block" do
- lambda { @klass.new.m(1) { } }.should raise_error(ArgumentError)
+ -> { @klass.new.m(1) { } }.should raise_error(ArgumentError)
end
it "receives an empty array as the third argument when passed two arguments" do
diff --git a/spec/ruby/core/module/define_singleton_method_spec.rb b/spec/ruby/core/module/define_singleton_method_spec.rb
index f2b8a5ada4..eb5cb89ed1 100644
--- a/spec/ruby/core/module/define_singleton_method_spec.rb
+++ b/spec/ruby/core/module/define_singleton_method_spec.rb
@@ -6,7 +6,7 @@ describe "Module#define_singleton_method" do
define_singleton_method :a do
42
end
- define_singleton_method(:b, lambda {|x| 2*x })
+ define_singleton_method(:b, -> x { 2*x })
end
klass.a.should == 42
diff --git a/spec/ruby/core/module/deprecate_constant_spec.rb b/spec/ruby/core/module/deprecate_constant_spec.rb
index 0954a6d8a5..7bcced981b 100644
--- a/spec/ruby/core/module/deprecate_constant_spec.rb
+++ b/spec/ruby/core/module/deprecate_constant_spec.rb
@@ -17,27 +17,27 @@ describe "Module#deprecate_constant" do
@module.deprecate_constant :PUBLIC1
value = nil
- lambda {
+ -> {
value = @module::PUBLIC1
}.should complain(@pattern)
value.should equal(@value)
- lambda { @module::PRIVATE }.should raise_error(NameError)
+ -> { @module::PRIVATE }.should raise_error(NameError)
end
it "warns with a message" do
@module.deprecate_constant :PUBLIC1
- lambda { @module::PUBLIC1 }.should complain(@pattern)
- lambda { @module.const_get :PRIVATE }.should complain(@pattern)
+ -> { @module::PUBLIC1 }.should complain(@pattern)
+ -> { @module.const_get :PRIVATE }.should complain(@pattern)
end
end
it "accepts multiple symbols and strings as constant names" do
@module.deprecate_constant "PUBLIC1", :PUBLIC2
- lambda { @module::PUBLIC1 }.should complain(@pattern)
- lambda { @module::PUBLIC2 }.should complain(@pattern)
+ -> { @module::PUBLIC1 }.should complain(@pattern)
+ -> { @module::PUBLIC2 }.should complain(@pattern)
end
it "returns self" do
@@ -45,6 +45,6 @@ describe "Module#deprecate_constant" do
end
it "raises a NameError when given an undefined name" do
- lambda { @module.deprecate_constant :UNDEFINED }.should raise_error(NameError)
+ -> { @module.deprecate_constant :UNDEFINED }.should raise_error(NameError)
end
end
diff --git a/spec/ruby/core/module/extend_object_spec.rb b/spec/ruby/core/module/extend_object_spec.rb
index df16f03ea0..bc97a55e7c 100644
--- a/spec/ruby/core/module/extend_object_spec.rb
+++ b/spec/ruby/core/module/extend_object_spec.rb
@@ -16,7 +16,7 @@ describe "Module#extend_object" do
end
it "raises a TypeError if calling after rebinded to Class" do
- lambda {
+ -> {
Module.instance_method(:extend_object).bind(Class.new).call Object.new
}.should raise_error(TypeError)
end
@@ -61,7 +61,7 @@ describe "Module#extend_object" do
end
it "raises a RuntimeError before extending the object" do
- lambda { @receiver.send(:extend_object, @object) }.should raise_error(RuntimeError)
+ -> { @receiver.send(:extend_object, @object) }.should raise_error(RuntimeError)
@object.should_not be_kind_of(@receiver)
end
end
diff --git a/spec/ruby/core/module/gt_spec.rb b/spec/ruby/core/module/gt_spec.rb
index adab89a78b..b8a73c9ff9 100644
--- a/spec/ruby/core/module/gt_spec.rb
+++ b/spec/ruby/core/module/gt_spec.rb
@@ -31,6 +31,6 @@ describe "Module#>" do
end
it "raises a TypeError if the argument is not a class/module" do
- lambda { ModuleSpecs::Parent > mock('x') }.should raise_error(TypeError)
+ -> { ModuleSpecs::Parent > mock('x') }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/module/gte_spec.rb b/spec/ruby/core/module/gte_spec.rb
index 945721fe6b..18c60ba586 100644
--- a/spec/ruby/core/module/gte_spec.rb
+++ b/spec/ruby/core/module/gte_spec.rb
@@ -28,6 +28,6 @@ describe "Module#>=" do
end
it "raises a TypeError if the argument is not a class/module" do
- lambda { ModuleSpecs::Parent >= mock('x') }.should raise_error(TypeError)
+ -> { ModuleSpecs::Parent >= mock('x') }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/module/include_spec.rb b/spec/ruby/core/module/include_spec.rb
index ece86bfe00..e7f99a5981 100644
--- a/spec/ruby/core/module/include_spec.rb
+++ b/spec/ruby/core/module/include_spec.rb
@@ -40,11 +40,11 @@ describe "Module#include" do
end
it "raises a TypeError when the argument is not a Module" do
- lambda { ModuleSpecs::Basic.include(Class.new) }.should raise_error(TypeError)
+ -> { ModuleSpecs::Basic.include(Class.new) }.should raise_error(TypeError)
end
it "does not raise a TypeError when the argument is an instance of a subclass of Module" do
- lambda { ModuleSpecs::SubclassSpec.include(ModuleSpecs::Subclass.new) }.should_not raise_error(TypeError)
+ -> { ModuleSpecs::SubclassSpec.include(ModuleSpecs::Subclass.new) }.should_not raise_error(TypeError)
end
it "imports constants to modules and classes" do
@@ -158,7 +158,7 @@ describe "Module#include" do
end
it "detects cyclic includes" do
- lambda {
+ -> {
module ModuleSpecs::M
include ModuleSpecs::M
end
@@ -166,7 +166,7 @@ describe "Module#include" do
end
it "doesn't accept no-arguments" do
- lambda {
+ -> {
Module.new do
include
end
@@ -252,7 +252,7 @@ describe "Module#include?" do
end
it "raises a TypeError when no module was given" do
- lambda { ModuleSpecs::Child.include?("Test") }.should raise_error(TypeError)
- lambda { ModuleSpecs::Child.include?(ModuleSpecs::Parent) }.should raise_error(TypeError)
+ -> { ModuleSpecs::Child.include?("Test") }.should raise_error(TypeError)
+ -> { ModuleSpecs::Child.include?(ModuleSpecs::Parent) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/module/instance_method_spec.rb b/spec/ruby/core/module/instance_method_spec.rb
index 9328df9179..b4d6a0d8c8 100644
--- a/spec/ruby/core/module/instance_method_spec.rb
+++ b/spec/ruby/core/module/instance_method_spec.rb
@@ -52,13 +52,13 @@ describe "Module#instance_method" do
end
it "raises a TypeError if not passed a symbol" do
- lambda { Object.instance_method([]) }.should raise_error(TypeError)
- lambda { Object.instance_method(0) }.should raise_error(TypeError)
+ -> { Object.instance_method([]) }.should raise_error(TypeError)
+ -> { Object.instance_method(0) }.should raise_error(TypeError)
end
it "raises a TypeError if the given name is not a string/symbol" do
- lambda { Object.instance_method(nil) }.should raise_error(TypeError)
- lambda { Object.instance_method(mock('x')) }.should raise_error(TypeError)
+ -> { Object.instance_method(nil) }.should raise_error(TypeError)
+ -> { Object.instance_method(mock('x')) }.should raise_error(TypeError)
end
it "raises a NameError if the method has been undefined" do
@@ -66,13 +66,13 @@ describe "Module#instance_method" do
child.send :undef_method, :foo
um = ModuleSpecs::InstanceMeth.instance_method(:foo)
um.should == @parent_um
- lambda do
+ -> do
child.instance_method(:foo)
end.should raise_error(NameError)
end
it "raises a NameError if the method does not exist" do
- lambda { Object.instance_method(:missing) }.should raise_error(NameError)
+ -> { Object.instance_method(:missing) }.should raise_error(NameError)
end
it "sets the NameError#name attribute to the name of the missing method" do
diff --git a/spec/ruby/core/module/lt_spec.rb b/spec/ruby/core/module/lt_spec.rb
index 1fd528a54e..d7771e07a8 100644
--- a/spec/ruby/core/module/lt_spec.rb
+++ b/spec/ruby/core/module/lt_spec.rb
@@ -31,6 +31,6 @@ describe "Module#<" do
end
it "raises a TypeError if the argument is not a class/module" do
- lambda { ModuleSpecs::Parent < mock('x') }.should raise_error(TypeError)
+ -> { ModuleSpecs::Parent < mock('x') }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/module/lte_spec.rb b/spec/ruby/core/module/lte_spec.rb
index b8252cfe55..7a0e8496b8 100644
--- a/spec/ruby/core/module/lte_spec.rb
+++ b/spec/ruby/core/module/lte_spec.rb
@@ -28,6 +28,6 @@ describe "Module#<=" do
end
it "raises a TypeError if the argument is not a class/module" do
- lambda { ModuleSpecs::Parent <= mock('x') }.should raise_error(TypeError)
+ -> { ModuleSpecs::Parent <= mock('x') }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/module/method_defined_spec.rb b/spec/ruby/core/module/method_defined_spec.rb
index f5203917b4..c2a8702d97 100644
--- a/spec/ruby/core/module/method_defined_spec.rb
+++ b/spec/ruby/core/module/method_defined_spec.rb
@@ -34,10 +34,10 @@ describe "Module#method_defined?" do
c = Class.new
o = mock('123')
- lambda { c.method_defined?(o) }.should raise_error(TypeError)
+ -> { c.method_defined?(o) }.should raise_error(TypeError)
o.should_receive(:to_str).and_return(123)
- lambda { c.method_defined?(o) }.should raise_error(TypeError)
+ -> { c.method_defined?(o) }.should raise_error(TypeError)
end
it "converts the given name to a string using to_str" do
diff --git a/spec/ruby/core/module/module_function_spec.rb b/spec/ruby/core/module/module_function_spec.rb
index 41d52849fd..407237d48f 100644
--- a/spec/ruby/core/module/module_function_spec.rb
+++ b/spec/ruby/core/module/module_function_spec.rb
@@ -12,11 +12,11 @@ describe "Module#module_function" do
end
it "raises a TypeError if calling after rebinded to Class" do
- lambda {
+ -> {
Module.instance_method(:module_function).bind(Class.new).call
}.should raise_error(TypeError)
- lambda {
+ -> {
Module.instance_method(:module_function).bind(Class.new).call :foo
}.should raise_error(TypeError)
end
@@ -87,7 +87,7 @@ describe "Module#module_function with specific method names" do
o.respond_to?(:test).should == false
m.should have_private_instance_method(:test)
o.send(:test).should == "hello"
- lambda { o.test }.should raise_error(NoMethodError)
+ -> { o.test }.should raise_error(NoMethodError)
end
it "makes the new Module methods public" do
@@ -116,10 +116,10 @@ describe "Module#module_function with specific method names" do
it "raises a TypeError when the given names can't be converted to string using to_str" do
o = mock('123')
- lambda { Module.new { module_function(o) } }.should raise_error(TypeError)
+ -> { Module.new { module_function(o) } }.should raise_error(TypeError)
o.should_receive(:to_str).and_return(123)
- lambda { Module.new { module_function(o) } }.should raise_error(TypeError)
+ -> { Module.new { module_function(o) } }.should raise_error(TypeError)
end
it "can make accessible private methods" do # JRUBY-4214
diff --git a/spec/ruby/core/module/prepend_features_spec.rb b/spec/ruby/core/module/prepend_features_spec.rb
index 2779073e9c..b6fce9aba0 100644
--- a/spec/ruby/core/module/prepend_features_spec.rb
+++ b/spec/ruby/core/module/prepend_features_spec.rb
@@ -23,7 +23,7 @@ describe "Module#prepend_features" do
end
it "raises an ArgumentError on a cyclic prepend" do
- lambda {
+ -> {
ModuleSpecs::CyclicPrepend.send(:prepend_features, ModuleSpecs::CyclicPrepend)
}.should raise_error(ArgumentError)
end
@@ -68,7 +68,7 @@ describe "Module#prepend_features" do
end
it "raises a TypeError if calling after rebinded to Class" do
- lambda {
+ -> {
Module.instance_method(:prepend_features).bind(Class.new).call Module.new
}.should raise_error(TypeError)
end
diff --git a/spec/ruby/core/module/prepend_spec.rb b/spec/ruby/core/module/prepend_spec.rb
index b186381640..e143f51673 100644
--- a/spec/ruby/core/module/prepend_spec.rb
+++ b/spec/ruby/core/module/prepend_spec.rb
@@ -37,11 +37,11 @@ describe "Module#prepend" do
end
it "raises a TypeError when the argument is not a Module" do
- lambda { ModuleSpecs::Basic.prepend(Class.new) }.should raise_error(TypeError)
+ -> { ModuleSpecs::Basic.prepend(Class.new) }.should raise_error(TypeError)
end
it "does not raise a TypeError when the argument is an instance of a subclass of Module" do
- lambda { ModuleSpecs::SubclassSpec.prepend(ModuleSpecs::Subclass.new) }.should_not raise_error(TypeError)
+ -> { ModuleSpecs::SubclassSpec.prepend(ModuleSpecs::Subclass.new) }.should_not raise_error(TypeError)
end
it "imports constants" do
@@ -204,7 +204,7 @@ describe "Module#prepend" do
super << :class
end
end
- lambda { c.new.chain }.should raise_error(NoMethodError)
+ -> { c.new.chain }.should raise_error(NoMethodError)
end
it "calls prepended after prepend_features" do
@@ -224,7 +224,7 @@ describe "Module#prepend" do
end
it "detects cyclic prepends" do
- lambda {
+ -> {
module ModuleSpecs::P
prepend ModuleSpecs::P
end
@@ -232,7 +232,7 @@ describe "Module#prepend" do
end
it "doesn't accept no-arguments" do
- lambda {
+ -> {
Module.new do
prepend
end
diff --git a/spec/ruby/core/module/private_class_method_spec.rb b/spec/ruby/core/module/private_class_method_spec.rb
index 73275b0e6b..e35b50d986 100644
--- a/spec/ruby/core/module/private_class_method_spec.rb
+++ b/spec/ruby/core/module/private_class_method_spec.rb
@@ -22,11 +22,11 @@ describe "Module#private_class_method" do
it "makes an existing class method private" do
ModuleSpecs::Parent.private_method_1.should == nil
ModuleSpecs::Parent.private_class_method :private_method_1
- lambda { ModuleSpecs::Parent.private_method_1 }.should raise_error(NoMethodError)
+ -> { ModuleSpecs::Parent.private_method_1 }.should raise_error(NoMethodError)
# Technically above we're testing the Singleton classes, class method(right?).
# Try a "real" class method set private.
- lambda { ModuleSpecs::Parent.private_method }.should raise_error(NoMethodError)
+ -> { ModuleSpecs::Parent.private_method }.should raise_error(NoMethodError)
end
it "makes an existing class method private up the inheritance tree" do
@@ -34,8 +34,8 @@ describe "Module#private_class_method" do
ModuleSpecs::Child.private_method_1.should == nil
ModuleSpecs::Child.private_class_method :private_method_1
- lambda { ModuleSpecs::Child.private_method_1 }.should raise_error(NoMethodError)
- lambda { ModuleSpecs::Child.private_method }.should raise_error(NoMethodError)
+ -> { ModuleSpecs::Child.private_method_1 }.should raise_error(NoMethodError)
+ -> { ModuleSpecs::Child.private_method }.should raise_error(NoMethodError)
end
it "accepts more than one method at a time" do
@@ -44,12 +44,12 @@ describe "Module#private_class_method" do
ModuleSpecs::Child.private_class_method :private_method_1, :private_method_2
- lambda { ModuleSpecs::Child.private_method_1 }.should raise_error(NoMethodError)
- lambda { ModuleSpecs::Child.private_method_2 }.should raise_error(NoMethodError)
+ -> { ModuleSpecs::Child.private_method_1 }.should raise_error(NoMethodError)
+ -> { ModuleSpecs::Child.private_method_2 }.should raise_error(NoMethodError)
end
it "raises a NameError if class method doesn't exist" do
- lambda do
+ -> do
ModuleSpecs.private_class_method :no_method_here
end.should raise_error(NameError)
end
@@ -59,11 +59,11 @@ describe "Module#private_class_method" do
def self.foo() "foo" end
private_class_method :foo
end
- lambda { c.foo }.should raise_error(NoMethodError)
+ -> { c.foo }.should raise_error(NoMethodError)
end
it "raises a NameError when the given name is not a method" do
- lambda do
+ -> do
Class.new do
private_class_method :foo
end
@@ -71,7 +71,7 @@ describe "Module#private_class_method" do
end
it "raises a NameError when the given name is an instance method" do
- lambda do
+ -> do
Class.new do
def foo() "foo" end
private_class_method :foo
diff --git a/spec/ruby/core/module/private_constant_spec.rb b/spec/ruby/core/module/private_constant_spec.rb
index 45aaec6c26..3a91b3c3cd 100644
--- a/spec/ruby/core/module/private_constant_spec.rb
+++ b/spec/ruby/core/module/private_constant_spec.rb
@@ -6,7 +6,7 @@ describe "Module#private_constant" do
cls1.const_set :Foo, true
cls2 = Class.new(cls1)
- lambda do
+ -> do
cls2.send :private_constant, :Foo
end.should raise_error(NameError)
end
@@ -16,7 +16,7 @@ describe "Module#private_constant" do
cls.const_set :Foo, true
cls.send :private_constant, "Foo"
- lambda { cls::Foo }.should raise_error(NameError)
+ -> { cls::Foo }.should raise_error(NameError)
end
it "accepts multiple names" do
@@ -26,7 +26,7 @@ describe "Module#private_constant" do
mod.send :private_constant, :Foo, :Bar
- lambda {mod::Foo}.should raise_error(NameError)
- lambda {mod::Bar}.should raise_error(NameError)
+ -> {mod::Foo}.should raise_error(NameError)
+ -> {mod::Bar}.should raise_error(NameError)
end
end
diff --git a/spec/ruby/core/module/private_method_defined_spec.rb b/spec/ruby/core/module/private_method_defined_spec.rb
index a3cf55852e..515542d9df 100644
--- a/spec/ruby/core/module/private_method_defined_spec.rb
+++ b/spec/ruby/core/module/private_method_defined_spec.rb
@@ -32,25 +32,25 @@ describe "Module#private_method_defined?" do
end
it "raises a TypeError if passed a Fixnum" do
- lambda do
+ -> do
ModuleSpecs::CountsMixin.private_method_defined?(1)
end.should raise_error(TypeError)
end
it "raises a TypeError if passed nil" do
- lambda do
+ -> do
ModuleSpecs::CountsMixin.private_method_defined?(nil)
end.should raise_error(TypeError)
end
it "raises a TypeError if passed false" do
- lambda do
+ -> do
ModuleSpecs::CountsMixin.private_method_defined?(false)
end.should raise_error(TypeError)
end
it "raises a TypeError if passed an object that does not defined #to_str" do
- lambda do
+ -> do
ModuleSpecs::CountsMixin.private_method_defined?(mock('x'))
end.should raise_error(TypeError)
end
@@ -59,7 +59,7 @@ describe "Module#private_method_defined?" do
sym = mock('symbol')
def sym.to_sym() :private_3 end
- lambda do
+ -> do
ModuleSpecs::CountsMixin.private_method_defined?(sym)
end.should raise_error(TypeError)
end
diff --git a/spec/ruby/core/module/private_spec.rb b/spec/ruby/core/module/private_spec.rb
index 5d85c34855..e893c24f38 100644
--- a/spec/ruby/core/module/private_spec.rb
+++ b/spec/ruby/core/module/private_spec.rb
@@ -17,7 +17,7 @@ describe "Module#private" do
private :foo
end
- lambda { obj.foo }.should raise_error(NoMethodError)
+ -> { obj.foo }.should raise_error(NoMethodError)
end
it "makes a public Object instance method private in a new module" do
@@ -47,7 +47,7 @@ describe "Module#private" do
end
it "raises a NameError when given an undefined name" do
- lambda do
+ -> do
Module.new.send(:private, :undefined)
end.should raise_error(NameError)
end
@@ -67,7 +67,7 @@ describe "Module#private" do
end
base.new.wrapped.should == 1
- lambda do
+ -> do
klass.new.wrapped
end.should raise_error(NameError)
end
diff --git a/spec/ruby/core/module/protected_method_defined_spec.rb b/spec/ruby/core/module/protected_method_defined_spec.rb
index 75e02e0433..7be7bdd3c9 100644
--- a/spec/ruby/core/module/protected_method_defined_spec.rb
+++ b/spec/ruby/core/module/protected_method_defined_spec.rb
@@ -32,25 +32,25 @@ describe "Module#protected_method_defined?" do
end
it "raises a TypeError if passed a Fixnum" do
- lambda do
+ -> do
ModuleSpecs::CountsMixin.protected_method_defined?(1)
end.should raise_error(TypeError)
end
it "raises a TypeError if passed nil" do
- lambda do
+ -> do
ModuleSpecs::CountsMixin.protected_method_defined?(nil)
end.should raise_error(TypeError)
end
it "raises a TypeError if passed false" do
- lambda do
+ -> do
ModuleSpecs::CountsMixin.protected_method_defined?(false)
end.should raise_error(TypeError)
end
it "raises a TypeError if passed an object that does not defined #to_str" do
- lambda do
+ -> do
ModuleSpecs::CountsMixin.protected_method_defined?(mock('x'))
end.should raise_error(TypeError)
end
@@ -59,7 +59,7 @@ describe "Module#protected_method_defined?" do
sym = mock('symbol')
def sym.to_sym() :protected_3 end
- lambda do
+ -> do
ModuleSpecs::CountsMixin.protected_method_defined?(sym)
end.should raise_error(TypeError)
end
diff --git a/spec/ruby/core/module/protected_spec.rb b/spec/ruby/core/module/protected_spec.rb
index 985e4621c5..aa04a42fb8 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
- lambda { ModuleSpecs::Parent.protected_method_1 }.should raise_error(NoMethodError)
+ -> { ModuleSpecs::Parent.protected_method_1 }.should raise_error(NoMethodError)
end
it "makes a public Object instance method protected in a new module" do
@@ -48,7 +48,7 @@ describe "Module#protected" do
end
it "raises a NameError when given an undefined name" do
- lambda do
+ -> do
Module.new.send(:protected, :undefined)
end.should raise_error(NameError)
end
diff --git a/spec/ruby/core/module/public_class_method_spec.rb b/spec/ruby/core/module/public_class_method_spec.rb
index 7745ed1f86..c09cc64863 100644
--- a/spec/ruby/core/module/public_class_method_spec.rb
+++ b/spec/ruby/core/module/public_class_method_spec.rb
@@ -18,7 +18,7 @@ describe "Module#public_class_method" do
end
it "makes an existing class method public" do
- lambda { ModuleSpecs::Parent.public_method_1 }.should raise_error(NoMethodError)
+ -> { ModuleSpecs::Parent.public_method_1 }.should raise_error(NoMethodError)
ModuleSpecs::Parent.public_class_method :public_method_1
ModuleSpecs::Parent.public_method_1.should == nil
@@ -29,7 +29,7 @@ describe "Module#public_class_method" do
it "makes an existing class method public up the inheritance tree" do
ModuleSpecs::Child.private_class_method :public_method_1
- lambda { ModuleSpecs::Child.public_method_1 }.should raise_error(NoMethodError)
+ -> { ModuleSpecs::Child.public_method_1 }.should raise_error(NoMethodError)
ModuleSpecs::Child.public_class_method :public_method_1
ModuleSpecs::Child.public_method_1.should == nil
@@ -37,8 +37,8 @@ describe "Module#public_class_method" do
end
it "accepts more than one method at a time" do
- lambda { ModuleSpecs::Parent.public_method_1 }.should raise_error(NameError)
- lambda { ModuleSpecs::Parent.public_method_2 }.should raise_error(NameError)
+ -> { ModuleSpecs::Parent.public_method_1 }.should raise_error(NameError)
+ -> { ModuleSpecs::Parent.public_method_2 }.should raise_error(NameError)
ModuleSpecs::Child.public_class_method :public_method_1, :public_method_2
@@ -47,7 +47,7 @@ describe "Module#public_class_method" do
end
it "raises a NameError if class method doesn't exist" do
- lambda do
+ -> do
ModuleSpecs.public_class_method :no_method_here
end.should raise_error(NameError)
end
@@ -62,7 +62,7 @@ describe "Module#public_class_method" do
end
it "raises a NameError when the given name is not a method" do
- lambda do
+ -> do
Class.new do
public_class_method :foo
end
@@ -70,7 +70,7 @@ describe "Module#public_class_method" do
end
it "raises a NameError when the given name is an instance method" do
- lambda do
+ -> do
Class.new do
def foo() "foo" end
public_class_method :foo
diff --git a/spec/ruby/core/module/public_constant_spec.rb b/spec/ruby/core/module/public_constant_spec.rb
index b2e6a08a4e..e624d45fd2 100644
--- a/spec/ruby/core/module/public_constant_spec.rb
+++ b/spec/ruby/core/module/public_constant_spec.rb
@@ -6,7 +6,7 @@ describe "Module#public_constant" do
cls1.const_set :Foo, true
cls2 = Class.new(cls1)
- lambda do
+ -> do
cls2.send :public_constant, :Foo
end.should raise_error(NameError)
end
diff --git a/spec/ruby/core/module/public_instance_method_spec.rb b/spec/ruby/core/module/public_instance_method_spec.rb
index aee6c03cf2..ba19ad0404 100644
--- a/spec/ruby/core/module/public_instance_method_spec.rb
+++ b/spec/ruby/core/module/public_instance_method_spec.rb
@@ -28,29 +28,29 @@ describe "Module#public_instance_method" do
end
it "raises a TypeError when given a name is not Symbol or String" do
- lambda { Module.new.public_instance_method(nil) }.should raise_error(TypeError)
+ -> { Module.new.public_instance_method(nil) }.should raise_error(TypeError)
end
it "raises a NameError when given a protected method name" do
- lambda do
+ -> do
ModuleSpecs::Basic.public_instance_method(:protected_module)
end.should raise_error(NameError)
end
it "raises a NameError if the method is private" do
- lambda do
+ -> do
ModuleSpecs::Basic.public_instance_method(:private_module)
end.should raise_error(NameError)
end
it "raises a NameError if the method has been undefined" do
- lambda do
+ -> do
ModuleSpecs::Parent.public_instance_method(:undefed_method)
end.should raise_error(NameError)
end
it "raises a NameError if the method does not exist" do
- lambda do
+ -> do
Module.new.public_instance_method(:missing)
end.should raise_error(NameError)
end
diff --git a/spec/ruby/core/module/public_method_defined_spec.rb b/spec/ruby/core/module/public_method_defined_spec.rb
index 0d7d3e031c..d2fcfd1e72 100644
--- a/spec/ruby/core/module/public_method_defined_spec.rb
+++ b/spec/ruby/core/module/public_method_defined_spec.rb
@@ -32,25 +32,25 @@ describe "Module#public_method_defined?" do
end
it "raises a TypeError if passed a Fixnum" do
- lambda do
+ -> do
ModuleSpecs::CountsMixin.public_method_defined?(1)
end.should raise_error(TypeError)
end
it "raises a TypeError if passed nil" do
- lambda do
+ -> do
ModuleSpecs::CountsMixin.public_method_defined?(nil)
end.should raise_error(TypeError)
end
it "raises a TypeError if passed false" do
- lambda do
+ -> do
ModuleSpecs::CountsMixin.public_method_defined?(false)
end.should raise_error(TypeError)
end
it "raises a TypeError if passed an object that does not defined #to_str" do
- lambda do
+ -> do
ModuleSpecs::CountsMixin.public_method_defined?(mock('x'))
end.should raise_error(TypeError)
end
@@ -59,7 +59,7 @@ describe "Module#public_method_defined?" do
sym = mock('symbol')
def sym.to_sym() :public_3 end
- lambda do
+ -> do
ModuleSpecs::CountsMixin.public_method_defined?(sym)
end.should raise_error(TypeError)
end
diff --git a/spec/ruby/core/module/public_spec.rb b/spec/ruby/core/module/public_spec.rb
index a948a55e5e..e7059f6aa6 100644
--- a/spec/ruby/core/module/public_spec.rb
+++ b/spec/ruby/core/module/public_spec.rb
@@ -37,7 +37,7 @@ describe "Module#public" do
end
it "raises a NameError when given an undefined name" do
- lambda do
+ -> do
Module.new.send(:public, :undefined)
end.should raise_error(NameError)
end
diff --git a/spec/ruby/core/module/refine_spec.rb b/spec/ruby/core/module/refine_spec.rb
index 7a1b2fc5fc..66c19ddb66 100644
--- a/spec/ruby/core/module/refine_spec.rb
+++ b/spec/ruby/core/module/refine_spec.rb
@@ -59,7 +59,7 @@ describe "Module#refine" do
end
it "raises ArgumentError if not passed an argument" do
- lambda do
+ -> do
Module.new do
refine {}
end
@@ -67,7 +67,7 @@ describe "Module#refine" do
end
it "raises TypeError if not passed a class" do
- lambda do
+ -> do
Module.new do
refine("foo") {}
end
@@ -88,7 +88,7 @@ describe "Module#refine" do
end
it "raises ArgumentError if not given a block" do
- lambda do
+ -> do
Module.new do
refine String
end
@@ -109,7 +109,7 @@ describe "Module#refine" do
it "doesn't apply refinements outside the refine block" do
Module.new do
refine(String) {def foo; "foo"; end}
- -> () {
+ -> {
"hello".foo
}.should raise_error(NoMethodError)
end
@@ -120,7 +120,7 @@ describe "Module#refine" do
refine(String) {def foo; 'foo'; end}
end
- lambda {"hello".foo}.should raise_error(NoMethodError)
+ -> {"hello".foo}.should raise_error(NoMethodError)
end
# When defining multiple refinements in the same module,
@@ -177,7 +177,7 @@ describe "Module#refine" do
result = nil
- -> () {
+ -> {
Module.new do
using refinery_integer
using refinery_array
@@ -575,7 +575,7 @@ describe "Module#refine" do
refinement = Module.new do
refine String do
def to_proc(*args)
- -> (*) { 'foo' }
+ -> * { 'foo' }
end
end
end
@@ -594,7 +594,7 @@ describe "Module#refine" do
refinement = Module.new do
refine String do
def to_proc(*args)
- -> (*) { 'foo' }
+ -> * { 'foo' }
end
end
end
@@ -689,7 +689,7 @@ describe "Module#refine" do
}
[1,2].orig_count.should == 2
end
- lambda { [1,2].orig_count }.should raise_error(NoMethodError)
+ -> { [1,2].orig_count }.should raise_error(NoMethodError)
end
it 'and alias_method aliases a method within a refinement module, but not outside it' do
@@ -701,7 +701,7 @@ describe "Module#refine" do
}
[1,2].orig_count.should == 2
end
- lambda { [1,2].orig_count }.should raise_error(NoMethodError)
+ -> { [1,2].orig_count }.should raise_error(NoMethodError)
end
# Refinements are inherited by module inclusion.
diff --git a/spec/ruby/core/module/remove_class_variable_spec.rb b/spec/ruby/core/module/remove_class_variable_spec.rb
index e431243ab4..ab9514adf6 100644
--- a/spec/ruby/core/module/remove_class_variable_spec.rb
+++ b/spec/ruby/core/module/remove_class_variable_spec.rb
@@ -23,19 +23,19 @@ describe "Module#remove_class_variable" do
it "raises a NameError when removing class variable declared in included module" do
c = ModuleSpecs::RemoveClassVariable.new { include ModuleSpecs::MVars.dup }
- lambda { c.send(:remove_class_variable, :@@mvar) }.should raise_error(NameError)
+ -> { c.send(:remove_class_variable, :@@mvar) }.should raise_error(NameError)
end
it "raises a NameError when passed a symbol with one leading @" do
- lambda { ModuleSpecs::MVars.send(:remove_class_variable, :@mvar) }.should raise_error(NameError)
+ -> { ModuleSpecs::MVars.send(:remove_class_variable, :@mvar) }.should raise_error(NameError)
end
it "raises a NameError when passed a symbol with no leading @" do
- lambda { ModuleSpecs::MVars.send(:remove_class_variable, :mvar) }.should raise_error(NameError)
+ -> { ModuleSpecs::MVars.send(:remove_class_variable, :mvar) }.should raise_error(NameError)
end
it "raises a NameError when an uninitialized class variable is given" do
- lambda { ModuleSpecs::MVars.send(:remove_class_variable, :@@nonexisting_class_variable) }.should raise_error(NameError)
+ -> { ModuleSpecs::MVars.send(:remove_class_variable, :@@nonexisting_class_variable) }.should raise_error(NameError)
end
it "is public" do
diff --git a/spec/ruby/core/module/remove_const_spec.rb b/spec/ruby/core/module/remove_const_spec.rb
index 073e2c1501..20eb2dc3ed 100644
--- a/spec/ruby/core/module/remove_const_spec.rb
+++ b/spec/ruby/core/module/remove_const_spec.rb
@@ -7,13 +7,13 @@ describe "Module#remove_const" do
ConstantSpecs::ModuleM::CS_CONST252.should == :const252
ConstantSpecs::ModuleM.send :remove_const, :CS_CONST252
- lambda { ConstantSpecs::ModuleM::CS_CONST252 }.should raise_error(NameError)
+ -> { ConstantSpecs::ModuleM::CS_CONST252 }.should raise_error(NameError)
ConstantSpecs::ModuleM::CS_CONST253 = :const253
ConstantSpecs::ModuleM::CS_CONST253.should == :const253
ConstantSpecs::ModuleM.send :remove_const, "CS_CONST253"
- lambda { ConstantSpecs::ModuleM::CS_CONST253 }.should raise_error(NameError)
+ -> { ConstantSpecs::ModuleM::CS_CONST253 }.should raise_error(NameError)
end
it "returns the value of the removed constant" do
@@ -23,7 +23,7 @@ describe "Module#remove_const" do
it "raises a NameError and does not call #const_missing if the constant is not defined" do
ConstantSpecs.should_not_receive(:const_missing)
- lambda { ConstantSpecs.send(:remove_const, :Nonexistent) }.should raise_error(NameError)
+ -> { ConstantSpecs.send(:remove_const, :Nonexistent) }.should raise_error(NameError)
end
it "raises a NameError and does not call #const_missing if the constant is not defined directly in the module" do
@@ -32,7 +32,7 @@ describe "Module#remove_const" do
ConstantSpecs::ContainerA::CS_CONST255.should == :const255
ConstantSpecs::ContainerA.should_not_receive(:const_missing)
- lambda do
+ -> do
ConstantSpecs::ContainerA.send :remove_const, :CS_CONST255
end.should raise_error(NameError)
ensure
@@ -41,21 +41,21 @@ describe "Module#remove_const" do
end
it "raises a NameError if the name does not start with a capital letter" do
- lambda { ConstantSpecs.send :remove_const, "name" }.should raise_error(NameError)
+ -> { ConstantSpecs.send :remove_const, "name" }.should raise_error(NameError)
end
it "raises a NameError if the name starts with a non-alphabetic character" do
- lambda { ConstantSpecs.send :remove_const, "__CONSTX__" }.should raise_error(NameError)
- lambda { ConstantSpecs.send :remove_const, "@Name" }.should raise_error(NameError)
- lambda { ConstantSpecs.send :remove_const, "!Name" }.should raise_error(NameError)
- lambda { ConstantSpecs.send :remove_const, "::Name" }.should raise_error(NameError)
+ -> { ConstantSpecs.send :remove_const, "__CONSTX__" }.should raise_error(NameError)
+ -> { ConstantSpecs.send :remove_const, "@Name" }.should raise_error(NameError)
+ -> { ConstantSpecs.send :remove_const, "!Name" }.should raise_error(NameError)
+ -> { ConstantSpecs.send :remove_const, "::Name" }.should raise_error(NameError)
end
it "raises a NameError if the name contains non-alphabetic characters except '_'" do
ConstantSpecs::ModuleM::CS_CONST256 = :const256
ConstantSpecs::ModuleM.send :remove_const, "CS_CONST256"
- lambda { ConstantSpecs.send :remove_const, "Name=" }.should raise_error(NameError)
- lambda { ConstantSpecs.send :remove_const, "Name?" }.should raise_error(NameError)
+ -> { ConstantSpecs.send :remove_const, "Name=" }.should raise_error(NameError)
+ -> { ConstantSpecs.send :remove_const, "Name?" }.should raise_error(NameError)
end
it "calls #to_str to convert the given name to a String" do
@@ -67,10 +67,10 @@ describe "Module#remove_const" do
it "raises a TypeError if conversion to a String by calling #to_str fails" do
name = mock('123')
- lambda { ConstantSpecs.send :remove_const, name }.should raise_error(TypeError)
+ -> { ConstantSpecs.send :remove_const, name }.should raise_error(TypeError)
name.should_receive(:to_str).and_return(123)
- lambda { ConstantSpecs.send :remove_const, name }.should raise_error(TypeError)
+ -> { ConstantSpecs.send :remove_const, name }.should raise_error(TypeError)
end
it "is a private method" do
diff --git a/spec/ruby/core/module/remove_method_spec.rb b/spec/ruby/core/module/remove_method_spec.rb
index 70048a83fb..ba08cc9b44 100644
--- a/spec/ruby/core/module/remove_method_spec.rb
+++ b/spec/ruby/core/module/remove_method_spec.rb
@@ -98,15 +98,15 @@ describe "Module#remove_method" do
end
it "raises a #{frozen_error_class} when passed a name" do
- lambda { @frozen.send :remove_method, :method_to_remove }.should raise_error(frozen_error_class)
+ -> { @frozen.send :remove_method, :method_to_remove }.should raise_error(frozen_error_class)
end
it "raises a #{frozen_error_class} when passed a missing name" do
- lambda { @frozen.send :remove_method, :not_exist }.should raise_error(frozen_error_class)
+ -> { @frozen.send :remove_method, :not_exist }.should raise_error(frozen_error_class)
end
it "raises a TypeError when passed a not name" do
- lambda { @frozen.send :remove_method, Object.new }.should raise_error(TypeError)
+ -> { @frozen.send :remove_method, Object.new }.should raise_error(TypeError)
end
it "does not raise exceptions when no arguments given" do
diff --git a/spec/ruby/core/module/shared/class_eval.rb b/spec/ruby/core/module/shared/class_eval.rb
index 6bb9668fee..08f8ff7597 100644
--- a/spec/ruby/core/module/shared/class_eval.rb
+++ b/spec/ruby/core/module/shared/class_eval.rb
@@ -14,7 +14,7 @@ describe :module_class_eval, shared: true do
'foo'
end
end
- lambda {42.foo}.should raise_error(NoMethodError)
+ -> {42.foo}.should raise_error(NoMethodError)
end
it "resolves constants in the caller scope" do
@@ -59,7 +59,7 @@ describe :module_class_eval, shared: true do
it "raises a TypeError when the given filename can't be converted to string using to_str" do
(file = mock('123')).should_receive(:to_str).and_return(123)
- lambda { ModuleSpecs.send(@method, "1+1", file) }.should raise_error(TypeError)
+ -> { ModuleSpecs.send(@method, "1+1", file) }.should raise_error(TypeError)
end
it "converts non string eval-string to string using to_str" do
@@ -69,24 +69,24 @@ describe :module_class_eval, shared: true do
it "raises a TypeError when the given eval-string can't be converted to string using to_str" do
o = mock('x')
- lambda { ModuleSpecs.send(@method, o) }.should raise_error(TypeError)
+ -> { ModuleSpecs.send(@method, o) }.should raise_error(TypeError)
(o = mock('123')).should_receive(:to_str).and_return(123)
- lambda { ModuleSpecs.send(@method, o) }.should raise_error(TypeError)
+ -> { ModuleSpecs.send(@method, o) }.should raise_error(TypeError)
end
it "raises an ArgumentError when no arguments and no block are given" do
- lambda { ModuleSpecs.send(@method) }.should raise_error(ArgumentError)
+ -> { ModuleSpecs.send(@method) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when more than 3 arguments are given" do
- lambda {
+ -> {
ModuleSpecs.send(@method, "1 + 1", "some file", 0, "bogus")
}.should raise_error(ArgumentError)
end
it "raises an ArgumentError when a block and normal arguments are given" do
- lambda {
+ -> {
ModuleSpecs.send(@method, "1 + 1") { 1 + 1 }
}.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/core/module/shared/class_exec.rb b/spec/ruby/core/module/shared/class_exec.rb
index c5c18b0a34..c7a9e5297f 100644
--- a/spec/ruby/core/module/shared/class_exec.rb
+++ b/spec/ruby/core/module/shared/class_exec.rb
@@ -5,7 +5,7 @@ describe :module_class_exec, shared: true do
'foo'
end
end
- lambda {42.foo}.should raise_error(NoMethodError)
+ -> {42.foo}.should raise_error(NoMethodError)
end
it "defines method in the receiver's scope" do
@@ -19,7 +19,7 @@ describe :module_class_exec, shared: true do
end
it "raises a LocalJumpError when no block is given" do
- lambda { ModuleSpecs::Subclass.send(@method) }.should raise_error(LocalJumpError)
+ -> { ModuleSpecs::Subclass.send(@method) }.should raise_error(LocalJumpError)
end
it "passes arguments to the block" do
diff --git a/spec/ruby/core/module/undef_method_spec.rb b/spec/ruby/core/module/undef_method_spec.rb
index 539de330e9..9b2c9240f4 100644
--- a/spec/ruby/core/module/undef_method_spec.rb
+++ b/spec/ruby/core/module/undef_method_spec.rb
@@ -41,8 +41,8 @@ describe "Module#undef_method" do
x = klass.new
klass.send(:undef_method, :method_to_undef, :another_method_to_undef)
- lambda { x.method_to_undef }.should raise_error(NoMethodError)
- lambda { x.another_method_to_undef }.should raise_error(NoMethodError)
+ -> { x.method_to_undef }.should raise_error(NoMethodError)
+ -> { x.another_method_to_undef }.should raise_error(NoMethodError)
end
it "does not undef any instance methods when argument not given" do
@@ -57,7 +57,7 @@ describe "Module#undef_method" do
end
it "raises a NameError when passed a missing name" do
- lambda { @module.send :undef_method, :not_exist }.should raise_error(NameError) { |e|
+ -> { @module.send :undef_method, :not_exist }.should raise_error(NameError) { |e|
# a NameError and not a NoMethodError
e.class.should == NameError
}
@@ -69,15 +69,15 @@ describe "Module#undef_method" do
end
it "raises a #{frozen_error_class} when passed a name" do
- lambda { @frozen.send :undef_method, :method_to_undef }.should raise_error(frozen_error_class)
+ -> { @frozen.send :undef_method, :method_to_undef }.should raise_error(frozen_error_class)
end
it "raises a #{frozen_error_class} when passed a missing name" do
- lambda { @frozen.send :undef_method, :not_exist }.should raise_error(frozen_error_class)
+ -> { @frozen.send :undef_method, :not_exist }.should raise_error(frozen_error_class)
end
it "raises a TypeError when passed a not name" do
- lambda { @frozen.send :undef_method, Object.new }.should raise_error(TypeError)
+ -> { @frozen.send :undef_method, Object.new }.should raise_error(TypeError)
end
it "does not raise exceptions when no arguments given" do
@@ -98,7 +98,7 @@ describe "Module#undef_method with symbol" do
klass.send :undef_method, :method_to_undef
- lambda { x.method_to_undef }.should raise_error(NoMethodError)
+ -> { x.method_to_undef }.should raise_error(NoMethodError)
end
it "removes a method defined in a super class" do
@@ -108,7 +108,7 @@ describe "Module#undef_method with symbol" do
child_class.send :undef_method, :method_to_undef
- lambda { child.method_to_undef }.should raise_error(NoMethodError)
+ -> { child.method_to_undef }.should raise_error(NoMethodError)
end
it "does not remove a method defined in a super class when removed from a subclass" do
@@ -134,7 +134,7 @@ describe "Module#undef_method with string" do
klass.send :undef_method, 'another_method_to_undef'
- lambda { x.another_method_to_undef }.should raise_error(NoMethodError)
+ -> { x.another_method_to_undef }.should raise_error(NoMethodError)
end
it "removes a method defined in a super class" do
@@ -144,7 +144,7 @@ describe "Module#undef_method with string" do
child_class.send :undef_method, 'another_method_to_undef'
- lambda { child.another_method_to_undef }.should raise_error(NoMethodError)
+ -> { child.another_method_to_undef }.should raise_error(NoMethodError)
end
it "does not remove a method defined in a super class when removed from a subclass" do
diff --git a/spec/ruby/core/module/using_spec.rb b/spec/ruby/core/module/using_spec.rb
index 9b6b38f622..533d87d080 100644
--- a/spec/ruby/core/module/using_spec.rb
+++ b/spec/ruby/core/module/using_spec.rb
@@ -24,7 +24,7 @@ describe "Module#using" do
end
end
- -> () {
+ -> {
Module.new do
using refinement
end
@@ -34,7 +34,7 @@ describe "Module#using" do
it "accepts module without refinements" do
mod = Module.new
- -> () {
+ -> {
Module.new do
using mod
end
@@ -44,7 +44,7 @@ describe "Module#using" do
it "does not accept class" do
klass = Class.new
- -> () {
+ -> {
Module.new do
using klass
end
@@ -52,7 +52,7 @@ describe "Module#using" do
end
it "raises TypeError if passed something other than module" do
- -> () {
+ -> {
Module.new do
using "foo"
end
@@ -93,7 +93,7 @@ describe "Module#using" do
end
end
- -> () {
+ -> {
mod.foo
}.should raise_error(RuntimeError, /Module#using is not permitted in methods/)
end