Sha256: 34a04f3f4fd42dbedf368d3f31d4f62662d2baa7add5e338f1025f3101a07e47

Contents?: true

Size: 1.1 KB

Versions: 8

Compression:

Stored size: 1.1 KB

Contents

require 'helper'
require 'cassanity/error'

describe Cassanity::Error do
  HorribleBadThing = Class.new(StandardError)

  it "can wrap original error" do
    original = HorribleBadThing.new
    error = described_class.new(original: original)
    error.original.should eq(original)
  end

  it "defaults original to last raised exception" do
    begin
      begin
        raise HorribleBadThing, 'Yep, really bad'
      rescue StandardError => e
        raise described_class
      end
    rescue described_class => e
      e.original.should be_instance_of(HorribleBadThing)
      e.message.should eq("Original Exception: HorribleBadThing: Yep, really bad")
    end
  end

  it "does not require original error" do
    error = described_class.new(:message => 'Is this thing on?')
    error.message.should eq('Is this thing on?')
  end

  it "works with only a string" do
    error = described_class.new("Is this thing on?")
    error.message.should eq('Is this thing on?')
  end

  it "does not require any arguments" do
    error = described_class.new
    error.message.should eq("Something truly horrible went wrong")
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cassanity-0.6.0 spec/unit/cassanity/error_spec.rb
cassanity-0.6.0.beta5 spec/unit/cassanity/error_spec.rb
cassanity-0.6.0.beta4 spec/unit/cassanity/error_spec.rb
cassanity-0.6.0.beta3 spec/unit/cassanity/error_spec.rb
cassanity-0.6.0.beta2 spec/unit/cassanity/error_spec.rb
cassanity-0.6.0.beta1 spec/unit/cassanity/error_spec.rb
cassanity-0.5.1 spec/unit/cassanity/error_spec.rb
cassanity-0.5.0 spec/unit/cassanity/error_spec.rb