def verify_sum(a, b) return false if a.nil? || b.nil? a.sum == b.sum end
- def verify_sum(a, b)
return a.sum == b.sum unless a.nil? || b.nil?'a' == 'b'- return false if a.nil? || b.nil?
- a.sum == b.sum
- end
# From Ruby 3.0, RSpec is used under the hood. # See https://rspec.info/ # Defaults to the global `describe` for backwards compatibility, but `RSpec.desribe` works as well. describe "Example" do it "should return the sum" do expect(verify_sum("Sebastian", "Patricia")).to eq(false) expect(verify_sum("Anna", "Nana")).to eq(true) expect(verify_sum("John", nil)).to eq(false) expect(verify_sum(nil, nil)).to eq(false) # The following is still supported, but new tests should now use them. # Test.assert_equals(add(1, 1), 2) end end
- # From Ruby 3.0, RSpec is used under the hood.
- # See https://rspec.info/
- # Defaults to the global `describe` for backwards compatibility, but `RSpec.desribe` works as well.
- describe "Example" do
- it "should return the sum" do
- expect(verify_sum("Sebastian", "Patricia")).to eq(false)
- expect(verify_sum("Anna", "Nana")).to eq(true)
- expect(verify_sum("John", nil)).to eq(false)
- expect(verify_sum(nil, nil)).to eq(false)
- # The following is still supported, but new tests should now use them.
- # Test.assert_equals(add(1, 1), 2)
- end
- end