summaryrefslogtreecommitdiff
path: root/spec/ruby/core/nil/singleton_method_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/nil/singleton_method_spec.rb')
-rw-r--r--spec/ruby/core/nil/singleton_method_spec.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/ruby/core/nil/singleton_method_spec.rb b/spec/ruby/core/nil/singleton_method_spec.rb
new file mode 100644
index 0000000000..f121b42f81
--- /dev/null
+++ b/spec/ruby/core/nil/singleton_method_spec.rb
@@ -0,0 +1,13 @@
+require_relative '../../spec_helper'
+
+describe "NilClass#singleton_method" do
+ it "raises regardless of whether NilClass defines the method" do
+ -> { nil.singleton_method(:foo) }.should.raise(NameError)
+ begin
+ def (nil).foo; end
+ -> { nil.singleton_method(:foo) }.should.raise(NameError)
+ ensure
+ NilClass.send(:remove_method, :foo)
+ end
+ end
+end