Sha256: b80ae091a12603dbf2fb5cd21fd70cd84ebed6aa783d7a87a6f861d902bff070

Contents?: true

Size: 1.47 KB

Versions: 3

Compression:

Stored size: 1.47 KB

Contents

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby_ext-0.4.11 spec/kernel_spec.rb
ruby_ext-0.4.10 spec/kernel_spec.rb
ruby_ext-0.4.9 spec/kernel_spec.rb