summaryrefslogtreecommitdiff
path: root/spec/ruby/core/regexp/encoding_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/regexp/encoding_spec.rb')
-rw-r--r--spec/ruby/core/regexp/encoding_spec.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/spec/ruby/core/regexp/encoding_spec.rb b/spec/ruby/core/regexp/encoding_spec.rb
index c30519c9d7..fb4fdba064 100644
--- a/spec/ruby/core/regexp/encoding_spec.rb
+++ b/spec/ruby/core/regexp/encoding_spec.rb
@@ -1,9 +1,9 @@
# -*- encoding: utf-8 -*-
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
describe "Regexp#encoding" do
it "returns an Encoding object" do
- /glar/.encoding.should be_an_instance_of(Encoding)
+ /glar/.encoding.should.instance_of?(Encoding)
end
it "defaults to US-ASCII if the Regexp contains only US-ASCII character" do
@@ -14,8 +14,8 @@ describe "Regexp#encoding" do
/ASCII/n.encoding.should == Encoding::US_ASCII
end
- it "returns ASCII-8BIT if the 'n' modifier is supplied and non-US-ASCII characters are present" do
- /\xc2\xa1/n.encoding.should == Encoding::ASCII_8BIT
+ it "returns BINARY if the 'n' modifier is supplied and non-US-ASCII characters are present" do
+ /\xc2\xa1/n.encoding.should == Encoding::BINARY
end
it "defaults to UTF-8 if \\u escapes appear" do
@@ -55,4 +55,8 @@ describe "Regexp#encoding" do
/foo/.encoding.should_not == Encoding::EUC_JP
Encoding.default_internal = old_internal
end
+
+ it "allows otherwise invalid characters if NOENCODING is specified" do
+ Regexp.new('([\x00-\xFF])', Regexp::IGNORECASE | Regexp::NOENCODING).encoding.should == Encoding::BINARY
+ end
end