Sha256: b651b232797db187b8e3e8cfdbc88b0a3234f4202d06a0b8d3479cbf232f7f9f

Contents?: true

Size: 818 Bytes

Versions: 2

Compression:

Stored size: 818 Bytes

Contents

describe Hallon::Error do
  subject { described_class }
  
  it { should <= RuntimeError }
  
  describe "::disambiguate" do
    it "should not fail on invalid numbers" do
      subject.disambiguate(10000).should eq [-1, nil]
    end
    
    it "should not fail on invalid symbols" do
      subject.disambiguate(:fail).should eq [-1, nil]
    end
  end
  
  describe "::explain" do
    it { subject.explain(0).should eq 'No error' }
    it { subject.explain(-1).should eq 'invalid error code' }
  end
  
  describe "::maybe_raise" do
    it "should not raise error when given 0 as error code" do
      expect { subject.maybe_raise(0) }.to_not raise_error
    end
    
    it "should raise error when given non-0 as error code" do
      expect { subject.maybe_raise(1) }.to raise_error(Hallon::Error)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hallon-0.1.1 spec/hallon/error_spec.rb
hallon-0.1.0 spec/hallon/error_spec.rb