Skip to content

Commit

Permalink
fix for frozen strings
Browse files Browse the repository at this point in the history
  • Loading branch information
fcoury committed Mar 28, 2012
1 parent 07400c8 commit 0b64edc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rainbow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def hide
def wrap_with_code(code) #:nodoc:
return self unless Sickill::Rainbow.enabled

var = self.clone
var = self.dup
matched = var.match(/^(\e\[([\d;]+)m)*/)
var.insert(matched.end(0), "\e[#{code}m")
var.concat("\e[0m") unless var =~ /\e\[0m$/
Expand Down
6 changes: 6 additions & 0 deletions test/rainbow_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ def test_immutability
assert_equal string, "hello"
end

def test_frozen
string = "frozen"
string.freeze
string.color(:red)
end

class MyString < String
end

Expand Down

0 comments on commit 0b64edc

Please sign in to comment.