Sha256: fa9852399b654263e75b72f5dc69c46478360b65091ff9950a4d7276f64ec429

Contents?: true

Size: 798 Bytes

Versions: 2

Compression:

Stored size: 798 Bytes

Contents

require 'spec_helper'
require 'ronin/extensions/kernel'

describe Kernel do
  it "should provide Kernel#attempt" do
    Kernel.should respond_to('attempt')
  end

  describe "attempt" do
    it "should return the result of the block if nothing is raised" do
      attempt { 2 + 2 }.should == 4
    end

    it "should return nil if an exception is raised" do
      attempt { 2 + 'a' }.should be_nil
    end

    it "should rescue RuntimeError exceptions" do
      lambda {
        attempt { raise(RuntimeError,"something happened",caller) }
      }.should_not raise_error(RuntimeError)
    end

    it "should rescue StandardError exceptions" do
      lambda {
        attempt { raise(StandardError,"not allowed to do that",caller) }
      }.should_not raise_error(StandardError)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ronin-support-0.1.0.pre2 spec/extensions/kernel_spec.rb
ronin-support-0.1.0.pre1 spec/extensions/kernel_spec.rb