Sha256: f268afd2d8c4a01cff24d25bb96a90b75970df91ac5e2c6c1126d8b229c9f3fb

Contents?: true

Size: 747 Bytes

Versions: 1

Compression:

Stored size: 747 Bytes

Contents

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

describe Kernel do
  it "should provide Kernel#try" do
    expect(Kernel).to respond_to('try')
  end

  describe "#try" do
    it "should return the result of the block if nothing is raised" do
      expect(try { 2 + 2 }).to eq(4)
    end

    it "should return nil if an exception is raised" do
      expect(try { 2 + 'a' }).to be_nil
    end

    it "should rescue RuntimeError exceptions" do
      expect {
        try { raise(RuntimeError,"something happened",caller) }
      }.not_to raise_error
    end

    it "should rescue StandardError exceptions" do
      expect {
        try { raise(StandardError,"not allowed to do that",caller) }
      }.not_to raise_error
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ronin-support-0.5.2 spec/extensions/kernel_spec.rb