aboutsummaryrefslogtreecommitdiffstats
path: root/spec/lib
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2014-03-13 17:29:14 +0000
committerLouise Crow <louise.crow@gmail.com>2014-03-13 17:29:14 +0000
commit5a435dfcb699b4f7b7d431cafc479ad92dcd6060 (patch)
tree157491659cc49f78ae3c50b8e50f1892c55be2ba /spec/lib
parent983b59d9006e62cfdb5890f46cccecf08e5d7cd4 (diff)
parenta6ed6bf242b224218a3e45ca0e0f0c7d18582a95 (diff)
Merge remote-tracking branch 'opennewzealand_github/feature/handle-undefined-conversion' into rails-3-develop
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/basic_encoding_spec.rb (renamed from spec/lib/basic_encoding_tests.rb)20
1 files changed, 10 insertions, 10 deletions
diff --git a/spec/lib/basic_encoding_tests.rb b/spec/lib/basic_encoding_spec.rb
index 35d35fd4a..43a65eab9 100644
--- a/spec/lib/basic_encoding_tests.rb
+++ b/spec/lib/basic_encoding_spec.rb
@@ -4,8 +4,8 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
def bytes_to_binary_string( bytes, claimed_encoding = nil )
claimed_encoding ||= 'ASCII-8BIT'
bytes_string = bytes.pack('c*')
- if RUBY_VERSION.to_f >= 1.9
- bytes_string.force_encoding! claimed_encoding
+ if String.method_defined?(:force_encoding)
+ bytes_string.force_encoding claimed_encoding
end
bytes_string
end
@@ -110,15 +110,15 @@ describe "convert_string_to_utf8_or_binary" do
converted = convert_string_to_utf8_or_binary random_string
converted.should == random_string
- if RUBY_VERSION.to_f >= 1.9
- converted.encoding.should == 'ASCII-8BIT'
+ if String.method_defined?(:encode)
+ converted.encoding.to_s.should == 'ASCII-8BIT'
end
converted = convert_string_to_utf8_or_binary random_string,'UTF-8'
converted.should == random_string
- if RUBY_VERSION.to_f >= 1.9
- converted.encoding.should == 'ASCII-8BIT'
+ if String.method_defined?(:encode)
+ converted.encoding.to_s.should == 'ASCII-8BIT'
end
end
@@ -132,8 +132,8 @@ describe "convert_string_to_utf8_or_binary" do
converted.should == "DASH – DASH"
- if RUBY_VERSION.to_f >= 1.9
- converted.encoding.should == 'UTF-8'
+ if String.method_defined?(:encode)
+ converted.encoding.to_s.should == 'UTF-8'
end
end
@@ -147,8 +147,8 @@ describe "convert_string_to_utf8_or_binary" do
converted.should start_with("贵公司负责人")
- if RUBY_VERSION.to_f >= 1.9
- converted.encoding.should == 'UTF-8'
+ if String.method_defined?(:encode)
+ converted.encoding.to_s.should == 'UTF-8'
end
end