def trim value value.to_s[1...-1] end require "spec" describe "#trim" do it { expect(trim "Foo Bar").to eq "oo Ba"} it { expect(trim "Foo").to eq "o"} it { expect(trim "Fo").to eq ""} it { expect(trim "F").to eq ""} it { expect(trim nil).to be_nil} it { expect(trim 777).to eq "7"} end
>> rspec debook_ends.rb ...... Finished in 0.00696 seconds (files took 0.15187 seconds to load) 6 examples, 0 failures
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Ruby Language Version
With specs
output