diff options
author | Benoit Daloze <eregontp@gmail.com> | 2019-07-27 12:40:09 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2019-07-27 12:40:09 +0200 |
commit | 5c276e1cc91c5ab2a41fbf7827af2fed914a2bc0 (patch) | |
tree | 05b5c68c8b2a00224d4646ea3b26ce3877efaadd /spec/ruby/core/module/const_get_spec.rb | |
parent | a06301b103371b0b7da8eaca26ba744961769f99 (diff) | |
download | ruby-5c276e1cc91c5ab2a41fbf7827af2fed914a2bc0.tar.gz |
Update to ruby/spec@875a09e
Diffstat (limited to 'spec/ruby/core/module/const_get_spec.rb')
-rw-r--r-- | spec/ruby/core/module/const_get_spec.rb | 44 |
1 files changed, 22 insertions, 22 deletions
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 |