diff options
Diffstat (limited to 'spec/ruby/language/undef_spec.rb')
| -rw-r--r-- | spec/ruby/language/undef_spec.rb | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/spec/ruby/language/undef_spec.rb b/spec/ruby/language/undef_spec.rb index 4e473b803f..98ecd99c21 100644 --- a/spec/ruby/language/undef_spec.rb +++ b/spec/ruby/language/undef_spec.rb @@ -14,35 +14,42 @@ describe "The undef keyword" do @undef_class.class_eval do undef meth end - -> { @obj.meth(5) }.should raise_error(NoMethodError) + -> { @obj.meth(5) }.should.raise(NoMethodError) end it "with a simple symbol" do @undef_class.class_eval do undef :meth end - -> { @obj.meth(5) }.should raise_error(NoMethodError) + -> { @obj.meth(5) }.should.raise(NoMethodError) end it "with a single quoted symbol" do @undef_class.class_eval do undef :'meth' end - -> { @obj.meth(5) }.should raise_error(NoMethodError) + -> { @obj.meth(5) }.should.raise(NoMethodError) end it "with a double quoted symbol" do @undef_class.class_eval do undef :"meth" end - -> { @obj.meth(5) }.should raise_error(NoMethodError) + -> { @obj.meth(5) }.should.raise(NoMethodError) end - it "with a interpolated symbol" do + it "with an interpolated symbol" do @undef_class.class_eval do undef :"#{'meth'}" end - -> { @obj.meth(5) }.should raise_error(NoMethodError) + -> { @obj.meth(5) }.should.raise(NoMethodError) + end + + it "with an interpolated symbol when interpolated expression is not a String literal" do + @undef_class.class_eval do + undef :"#{'meth'.to_sym}" + end + -> { @obj.meth(5) }.should.raise(NoMethodError) end end @@ -62,8 +69,8 @@ describe "The undef keyword" do it "raises a NameError when passed a missing name" do Class.new do -> { - undef not_exist - }.should raise_error(NameError) { |e| + undef not_exist + }.should.raise(NameError) { |e| # a NameError and not a NoMethodError e.class.should == NameError } |
