Sha256: 61a2e865757642e4768aa358792cb0f92184caad9f4a8b99c323ee56aab239dd

Contents?: true

Size: 820 Bytes

Versions: 4

Compression:

Stored size: 820 Bytes

Contents

RSpec.describe "Kernel#raise_error" do

  # Call specs directly on Kernel, which you would usually do implicit
  # instead of explicit, in order to escape the RSpec namespace, which has
  # it's own effects for raised errors

  it "should define a new constant, if the error class does not yet exist" do
    
    begin
      Kernel.raise_error "ThisErrorWillProbablyNotExistError"
    rescue
    end

    expect(Kernel.const_defined?('ThisErrorWillProbablyNotExistError')).to eq true

  end

  it "should call an existing constant, if the error class already exists" do
    
    expect(Kernel.const_defined?('StandardError'))
    initial_const_count = Module.constants.count

    begin
      Kernel.raise_error "StandardError"
    rescue
    end

    expect(Module.constants.count).to eq initial_const_count

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
eitil-1.2.4 spec/eitil_core/errors/raise_error_spec.rb
eitil-1.2.3 spec/eitil_core/errors/raise_error_spec.rb
eitil-1.2.2 spec/eitil_core/errors/raise_error_spec.rb
eitil-1.2.1 spec/eitil_core/errors/raise_error_spec.rb