require "spec_helper" require "ruby_ext/kernel" describe 'Kernel' do class Respond def test; 2 end end after :all do [:TheNamespace, :AnotherClass].each{|c| Object.send :remove_const, c if Object.const_defined? c} end it "respond_to" do r = Respond.new r.respond_to(:not_exist).should be_nil r.respond_to(:test).should == 2 end it "raise_without_self" do dir = File.dirname __FILE__ require "#{dir}/kernel_spec/TheNamespace/ClassA" require "#{dir}/kernel_spec/the_namespace/class_b" require "#{dir}/kernel_spec/another_class" begin TheNamespace::ClassA.problem_method rescue StandardError => e e.message.should =~ /Some problem/ stack = e.backtrace stack.any?{|line| line =~ /ClassA/}.should be_false stack.any?{|line| line =~ /kernel_spec/}.should be_true end begin TheNamespace::ClassB.problem_method rescue StandardError => e e.message.should =~ /Some problem/ stack = e.backtrace stack.any?{|line| line =~ /class_b/}.should be_false stack.any?{|line| line =~ /kernel_spec/}.should be_true end begin AnotherClass.exclude_multiple_classes rescue StandardError => e e.message.should =~ /Some problem/ stack = e.backtrace stack.any?{|line| line =~ /class_b/}.should be_false stack.any?{|line| line =~ /another_class/}.should be_false stack.any?{|line| line =~ /kernel_spec/}.should be_true end end end