summaryrefslogtreecommitdiff
path: root/spec/ruby/core/nil/singleton_method_spec.rb
blob: fb47af0c3e8c5d201390485f754e02291264bb08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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_error(NameError)
    begin
      def (nil).foo; end
      -> { nil.singleton_method(:foo) }.should raise_error(NameError)
    ensure
      NilClass.send(:remove_method, :foo)
    end
  end
end