Sha256: 460c0188a92b77292c445a915e043ec6b149d593527cb1d45ac933d1d170030a

Contents?: true

Size: 794 Bytes

Versions: 24

Compression:

Stored size: 794 Bytes

Contents

# For some reason, the Kernel patches – which ruby mixes into Object – are not
# available to the tests, therefore load the file manually.
load (Eitil::Root + "/eitil_core/lib/eitil_core/safe_executions/safe_call.rb")

RSpec.describe "EitilCore Object#safe_call" do

  it "should return the block's yield value, if no error is raised" do
    result = Object.new.safe_call { 1 + 1 }
    expect(result).to eq 2
  end

  it "should by default return nil, if an error is raised" do
    result = Object.new.safe_call { raise(StandardError) }
    expect(result).to be_nil
  end

  it "should return the specified :return_value, if an error is raised" do
    result = Object.new.safe_call(return_value: :something_else) { raise(StandardError) }
    expect(result).to eq :something_else
  end

end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
eitil-2.0.8 spec/eitil_core/safe_executions/safe_call.rb
eitil-2.0.7 spec/eitil_core/safe_executions/safe_call.rb
eitil-2.0.6 spec/eitil_core/safe_executions/safe_call.rb
eitil-2.0.5 spec/eitil_core/safe_executions/safe_call.rb
eitil-2.0.4 spec/eitil_core/safe_executions/safe_call.rb
eitil-2.0.3 spec/eitil_core/safe_executions/safe_call.rb
eitil-2.0.2 spec/eitil_core/safe_executions/safe_call.rb
eitil-2.0.1 spec/eitil_core/safe_executions/safe_call.rb
eitil-2.0.0 spec/eitil_core/safe_executions/safe_call.rb
eitil-1.4.1 spec/eitil_core/safe_executions/safe_call.rb
eitil-1.4.0 spec/eitil_core/safe_executions/safe_call.rb
eitil-1.3.12 spec/eitil_core/safe_executions/safe_call.rb
eitil-1.3.11 spec/eitil_core/safe_executions/safe_call.rb
eitil-1.3.10 spec/eitil_core/safe_executions/safe_call.rb
eitil-1.3.9 spec/eitil_core/safe_executions/safe_call.rb
eitil-1.3.8 spec/eitil_core/safe_executions/safe_call.rb
eitil-1.3.7 spec/eitil_core/safe_executions/safe_call.rb
eitil-1.3.6 spec/eitil_core/safe_executions/safe_call.rb
eitil-1.3.5 spec/eitil_core/safe_executions/safe_call.rb
eitil-1.3.4 spec/eitil_core/safe_executions/safe_call.rb