Sha256: 7c6dd8a818e20026e5c59ea68193a47754250cc9ad0d55a75b9c9306ce90081c

Contents?: true

Size: 860 Bytes

Versions: 24

Compression:

Stored size: 860 Bytes

Contents

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

RSpec.describe "EitilCore Object#safe_send" do

  let(:string) { "Hiya, Cowboy!" }

  it "should return the method's return value, if no error is raised" do 
    result = string.safe_send(:upcase)
    expect(result).to eq "HIYA, COWBOY!"
  end

  it "should by default return nil, if an error is raised" do
    result = string.safe_send(:this_method_does_probably_not_exist)
    expect(result).to be_nil
  end

  it "should return the specified :return_value, if an error is raised" do
    result = string.safe_send(:this_method_does_probably_not_exist, return_value: :something_else)
    expect(result).to eq :something_else
  end

end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
eitil-1.3.3 spec/eitil_core/safe_executions/safe_send.rb
eitil-1.3.2 spec/eitil_core/safe_executions/safe_send.rb
eitil-1.3.1 spec/eitil_core/safe_executions/safe_send.rb
eitil-1.3.0 spec/eitil_core/safe_executions/safe_send.rb