Skip to content

Commit

Permalink
Fix specs for yield in singleton class being deprecated
Browse files Browse the repository at this point in the history
* Use eval to trigger warning only when the method is called.
* Suppress warnings and clarify this will be removed in 3.0.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67031 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
eregon committed Feb 21, 2019
1 parent 53daec9 commit 2a5b864
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions fixtures/class.rb
@@ -1,9 +1,11 @@
module ClassSpecs

def self.sclass_with_block
eval <<-RUBY
class << self
yield
end
RUBY
end

def self.sclass_with_return
Expand Down
8 changes: 6 additions & 2 deletions language/class_spec.rb
Expand Up @@ -285,8 +285,12 @@ def xyz
}.should raise_error(TypeError)
end

it "allows accessing the block of the original scope" do
ClassSpecs.sclass_with_block { 123 }.should == 123
ruby_version_is ""..."3.0" do
it "allows accessing the block of the original scope" do
suppress_warning do
ClassSpecs.sclass_with_block { 123 }.should == 123
end
end
end

it "can use return to cause the enclosing method to return" do
Expand Down

0 comments on commit 2a5b864

Please sign in to comment.