Sha256: 45e5a8c180f0a9122b7d5c70c4d17f79add500ac8713a67a333b7fba6c9a95a7

Contents?: true

Size: 1.4 KB

Versions: 14

Compression:

Stored size: 1.4 KB

Contents

require "core/spec_helper"

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
    require "#{spec_dir}/TheNamespace/ClassA"
    require "#{spec_dir}/the_namespace/class_b"
    require "#{spec_dir}/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

14 entries across 14 versions & 1 rubygems

Version Path
ruby_ext-0.4.25 spec/core/kernel_spec.rb
ruby_ext-0.4.24 spec/core/kernel_spec.rb
ruby_ext-0.4.23 spec/core/kernel_spec.rb
ruby_ext-0.4.22 spec/core/kernel_spec.rb
ruby_ext-0.4.21 spec/core/kernel_spec.rb
ruby_ext-0.4.20 spec/core/kernel_spec.rb
ruby_ext-0.4.19 spec/core/kernel_spec.rb
ruby_ext-0.4.18 spec/core/kernel_spec.rb
ruby_ext-0.4.17 spec/core/kernel_spec.rb
ruby_ext-0.4.16 spec/core/kernel_spec.rb
ruby_ext-0.4.15 spec/core/kernel_spec.rb
ruby_ext-0.4.14 spec/core/kernel_spec.rb
ruby_ext-0.4.13 spec/core/kernel_spec.rb
ruby_ext-0.4.12 spec/core/kernel_spec.rb