summaryrefslogtreecommitdiff
path: root/spec/ruby/language/symbol_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/language/symbol_spec.rb')
-rw-r--r--spec/ruby/language/symbol_spec.rb38
1 files changed, 20 insertions, 18 deletions
diff --git a/spec/ruby/language/symbol_spec.rb b/spec/ruby/language/symbol_spec.rb
index 90540f7d1d..81fe06b50b 100644
--- a/spec/ruby/language/symbol_spec.rb
+++ b/spec/ruby/language/symbol_spec.rb
@@ -1,9 +1,9 @@
-require File.expand_path('../../spec_helper', __FILE__)
+require_relative '../spec_helper'
describe "A Symbol literal" do
it "is a ':' followed by any number of valid characters" do
a = :foo
- a.should be_kind_of(Symbol)
+ a.should.is_a?(Symbol)
a.inspect.should == ':foo'
end
@@ -21,7 +21,7 @@ describe "A Symbol literal" do
:_Foo,
:&,
:_9
- ].each { |s| s.should be_kind_of(Symbol) }
+ ].each { |s| s.should.is_a?(Symbol) }
end
it "is a ':' followed by a single- or double-quoted string that may contain otherwise invalid characters" do
@@ -31,33 +31,33 @@ describe "A Symbol literal" do
[:"foo #{1 + 1}", ':"foo 2"'],
[:"foo\nbar", ':"foo\nbar"'],
].each { |sym, str|
- sym.should be_kind_of(Symbol)
+ sym.should.is_a?(Symbol)
sym.inspect.should == str
}
end
it 'inherits the encoding of the magic comment and can have a binary encoding' do
ruby_exe(fixture(__FILE__, "binary_symbol.rb"))
- .should == "[105, 108, 95, 195, 169, 116, 97, 105, 116]\nASCII-8BIT\n"
+ .should == "[105, 108, 95, 195, 169, 116, 97, 105, 116]\n#{Encoding::BINARY.name}\n"
end
it "may contain '::' in the string" do
- :'Some::Class'.should be_kind_of(Symbol)
+ :'Some::Class'.should.is_a?(Symbol)
end
it "is converted to a literal, unquoted representation if the symbol contains only valid characters" do
a, b, c = :'foo', :'+', :'Foo__9'
- a.should be_kind_of(Symbol)
+ a.should.is_a?(Symbol)
a.inspect.should == ':foo'
- b.should be_kind_of(Symbol)
+ b.should.is_a?(Symbol)
b.inspect.should == ':+'
- c.should be_kind_of(Symbol)
+ c.should.is_a?(Symbol)
c.inspect.should == ':Foo__9'
end
it "can be created by the %s-delimited expression" do
a, b = :'foo bar', %s{foo bar}
- b.should be_kind_of(Symbol)
+ b.should.is_a?(Symbol)
b.inspect.should == ':"foo bar"'
b.should == a
end
@@ -68,7 +68,7 @@ describe "A Symbol literal" do
[:'a string', :'a string'],
[:"#{var}", :"#{var}"]
].each { |a, b|
- a.should equal(b)
+ a.should.equal?(b)
}
end
@@ -78,7 +78,7 @@ describe "A Symbol literal" do
it "can be an empty string" do
c = :''
- c.should be_kind_of(Symbol)
+ c.should.is_a?(Symbol)
c.inspect.should == ':""'
end
@@ -96,11 +96,13 @@ describe "A Symbol literal" do
%I{a b #{"c"}}.should == [:a, :b, :c]
end
- it "with invalid bytes raises an EncodingError at parse time" do
- ScratchPad.record []
- -> {
- eval 'ScratchPad << 1; :"\xC3"'
- }.should raise_error(EncodingError, /invalid/)
- ScratchPad.recorded.should == []
+ ruby_bug "#20280", ""..."3.4" do
+ it "raises an SyntaxError at parse time when Symbol with invalid bytes" do
+ ScratchPad.record []
+ -> {
+ eval 'ScratchPad << 1; :"\xC3"'
+ }.should.raise(SyntaxError, /invalid symbol/)
+ ScratchPad.recorded.should == []
+ end
end
end