mirror of
https://github.com/athityakumar/colorls.git
synced 2024-09-12 05:31:14 +02:00
Clean up monkey patches
* delete `#remove` method
* remove `#delete_prefix` spec, it was only used for Ruby < 2.5 (see 86cfa2f5cf
)
* add specifications for `#colorize` and `#uniq`
This commit is contained in:
parent
dc12307f19
commit
a59258b749
2 changed files with 11 additions and 25 deletions
|
@ -5,10 +5,6 @@ class String
|
|||
self.color(color)
|
||||
end
|
||||
|
||||
def remove(pattern)
|
||||
gsub(pattern, '')
|
||||
end
|
||||
|
||||
def uniq
|
||||
split('').uniq.join
|
||||
end
|
||||
|
|
|
@ -1,23 +1,13 @@
|
|||
require 'colorls/monkeys'
|
||||
|
||||
RSpec.describe "String#delete_prefix" do
|
||||
# back compat for Ruby < 2.5
|
||||
|
||||
it "returns a copy of the string, with the given prefix removed" do
|
||||
expect('hello'.delete_prefix('hell')).to eq 'o'
|
||||
expect('hello'.delete_prefix('hello')).to eq ''
|
||||
end
|
||||
|
||||
it "returns a copy of the string, when the prefix isn't found" do
|
||||
s = 'hello'
|
||||
r = s.delete_prefix('hello!')
|
||||
expect(r).not_to equal s
|
||||
expect(r).to be == s
|
||||
r = s.delete_prefix('ell')
|
||||
expect(r).not_to equal s
|
||||
expect(r).to be == s
|
||||
r = s.delete_prefix('')
|
||||
expect(r).not_to equal s
|
||||
expect(r).to be == s
|
||||
end
|
||||
|
||||
RSpec.describe String, '#uniq' do
|
||||
it 'removes all duplicate characters' do
|
||||
expect('abca'.uniq).to be == 'abc'
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.describe String, '#colorize' do
|
||||
it 'colors a string with red' do
|
||||
expect('hello'.colorize(:red)).to be == Rainbow('hello').red
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue