Skip to content
Browse files

Avoid mutating the constants in a test case

  • Loading branch information...
1 parent 5643cac commit cc9d1c52012cd9d7c3f55fd3fe4032080f83b4f2 @amatsuda amatsuda committed Aug 16, 2014
Showing with 4 additions and 6 deletions.
  1. +1 −3 activesupport/test/multibyte_chars_test.rb
  2. +3 −3 activesupport/test/multibyte_test_helpers.rb
View
4 activesupport/test/multibyte_chars_test.rb
@@ -8,7 +8,7 @@ class MultibyteCharsTest < ActiveSupport::TestCase
def setup
@proxy_class = ActiveSupport::Multibyte::Chars
- @chars = @proxy_class.new UNICODE_STRING
+ @chars = @proxy_class.new UNICODE_STRING.dup
end
def test_wraps_the_original_string
@@ -50,8 +50,6 @@ def test_forwarded_bang_method_calls_should_return_nil_when_result_is_nil
def test_methods_are_forwarded_to_wrapped_string_for_byte_strings
original_encoding = BYTE_STRING.encoding
assert_equal BYTE_STRING.length, BYTE_STRING.mb_chars.length
- ensure
- BYTE_STRING.force_encoding(original_encoding)
end
def test_forwarded_method_with_non_string_result_should_be_returned_vertabim
View
6 activesupport/test/multibyte_test_helpers.rb
@@ -1,9 +1,9 @@
# encoding: utf-8
module MultibyteTestHelpers
- UNICODE_STRING = 'こにちわ'
- ASCII_STRING = 'ohayo'
- BYTE_STRING = "\270\236\010\210\245".force_encoding("ASCII-8BIT")
+ UNICODE_STRING = 'こにちわ'.freeze
+ ASCII_STRING = 'ohayo'.freeze
+ BYTE_STRING = "\270\236\010\210\245".force_encoding("ASCII-8BIT").freeze
def chars(str)
ActiveSupport::Multibyte::Chars.new(str)

0 comments on commit cc9d1c5

Please sign in to comment.
Something went wrong with that request. Please try again.