diff options
Diffstat (limited to 'spec/ruby/core/symbol')
| -rw-r--r-- | spec/ruby/core/symbol/all_symbols_spec.rb | 8 | ||||
| -rw-r--r-- | spec/ruby/core/symbol/capitalize_spec.rb | 2 | ||||
| -rw-r--r-- | spec/ruby/core/symbol/casecmp_spec.rb | 14 | ||||
| -rw-r--r-- | spec/ruby/core/symbol/comparison_spec.rb | 6 | ||||
| -rw-r--r-- | spec/ruby/core/symbol/downcase_spec.rb | 2 | ||||
| -rw-r--r-- | spec/ruby/core/symbol/dup_spec.rb | 2 | ||||
| -rw-r--r-- | spec/ruby/core/symbol/empty_spec.rb | 4 | ||||
| -rw-r--r-- | spec/ruby/core/symbol/inspect_spec.rb | 34 | ||||
| -rw-r--r-- | spec/ruby/core/symbol/intern_spec.rb | 2 | ||||
| -rw-r--r-- | spec/ruby/core/symbol/match_spec.rb | 18 | ||||
| -rw-r--r-- | spec/ruby/core/symbol/name_spec.rb | 24 | ||||
| -rw-r--r-- | spec/ruby/core/symbol/shared/id2name.rb | 21 | ||||
| -rw-r--r-- | spec/ruby/core/symbol/shared/slice.rb | 58 | ||||
| -rw-r--r-- | spec/ruby/core/symbol/swapcase_spec.rb | 2 | ||||
| -rw-r--r-- | spec/ruby/core/symbol/symbol_spec.rb | 4 | ||||
| -rw-r--r-- | spec/ruby/core/symbol/to_proc_spec.rb | 87 | ||||
| -rw-r--r-- | spec/ruby/core/symbol/upcase_spec.rb | 2 |
17 files changed, 161 insertions, 129 deletions
diff --git a/spec/ruby/core/symbol/all_symbols_spec.rb b/spec/ruby/core/symbol/all_symbols_spec.rb index 1e21809093..689f6211de 100644 --- a/spec/ruby/core/symbol/all_symbols_spec.rb +++ b/spec/ruby/core/symbol/all_symbols_spec.rb @@ -3,17 +3,17 @@ require_relative '../../spec_helper' describe "Symbol.all_symbols" do it "returns an array of Symbols" do all_symbols = Symbol.all_symbols - all_symbols.should be_an_instance_of(Array) - all_symbols.each { |s| s.should be_an_instance_of(Symbol) } + all_symbols.should.instance_of?(Array) + all_symbols.each { |s| s.should.instance_of?(Symbol) } end it "includes symbols that are strongly referenced" do symbol = "symbol_specs_#{rand(5_000_000)}".to_sym - Symbol.all_symbols.should include(symbol) + Symbol.all_symbols.should.include?(symbol) end it "includes symbols that are referenced in source code but not yet executed" do - Symbol.all_symbols.any? { |s| s.to_s == 'symbol_specs_referenced_in_source_code' }.should be_true + Symbol.all_symbols.any? { |s| s.to_s == 'symbol_specs_referenced_in_source_code' }.should == true :symbol_specs_referenced_in_source_code end end diff --git a/spec/ruby/core/symbol/capitalize_spec.rb b/spec/ruby/core/symbol/capitalize_spec.rb index a84bcf280a..a93d951e6a 100644 --- a/spec/ruby/core/symbol/capitalize_spec.rb +++ b/spec/ruby/core/symbol/capitalize_spec.rb @@ -3,7 +3,7 @@ require_relative '../../spec_helper' describe "Symbol#capitalize" do it "returns a Symbol" do - :glark.capitalize.should be_an_instance_of(Symbol) + :glark.capitalize.should.instance_of?(Symbol) end it "converts the first character to uppercase if it is ASCII" do diff --git a/spec/ruby/core/symbol/casecmp_spec.rb b/spec/ruby/core/symbol/casecmp_spec.rb index 80ea51e910..dcb77a8350 100644 --- a/spec/ruby/core/symbol/casecmp_spec.rb +++ b/spec/ruby/core/symbol/casecmp_spec.rb @@ -56,20 +56,24 @@ describe "Symbol#casecmp with Symbol" do lower_a_tilde.casecmp(upper_a_tilde).should == 1 lower_a_umlaut.casecmp(upper_a_umlaut).should == 1 end + + it "returns 0 for empty strings in different encodings" do + ''.to_sym.casecmp(''.encode("UTF-32LE").to_sym).should == 0 + end end describe "Symbol#casecmp" do it "returns nil if other is a String" do - :abc.casecmp("abc").should be_nil + :abc.casecmp("abc").should == nil end it "returns nil if other is an Integer" do - :abc.casecmp(1).should be_nil + :abc.casecmp(1).should == nil end it "returns nil if other is an object" do obj = mock("string <=>") - :abc.casecmp(obj).should be_nil + :abc.casecmp(obj).should == nil end end @@ -141,4 +145,8 @@ describe 'Symbol#casecmp?' do upper_a_tilde.casecmp?(lower_a_tilde).should == nil lower_a_tilde.casecmp?(upper_a_tilde).should == nil end + + it "returns true for empty symbols in different encodings" do + ''.to_sym.should.casecmp?(''.encode("UTF-32LE").to_sym) + end end diff --git a/spec/ruby/core/symbol/comparison_spec.rb b/spec/ruby/core/symbol/comparison_spec.rb index 613177be05..6d56176e97 100644 --- a/spec/ruby/core/symbol/comparison_spec.rb +++ b/spec/ruby/core/symbol/comparison_spec.rb @@ -37,15 +37,15 @@ end describe "Symbol#<=>" do it "returns nil if other is a String" do - (:abc <=> "abc").should be_nil + (:abc <=> "abc").should == nil end it "returns nil if other is an Integer" do - (:abc <=> 1).should be_nil + (:abc <=> 1).should == nil end it "returns nil if other is an object" do obj = mock("string <=>") - (:abc <=> obj).should be_nil + (:abc <=> obj).should == nil end end diff --git a/spec/ruby/core/symbol/downcase_spec.rb b/spec/ruby/core/symbol/downcase_spec.rb index 7e94c669cc..76418aa9da 100644 --- a/spec/ruby/core/symbol/downcase_spec.rb +++ b/spec/ruby/core/symbol/downcase_spec.rb @@ -3,7 +3,7 @@ require_relative '../../spec_helper' describe "Symbol#downcase" do it "returns a Symbol" do - :glark.downcase.should be_an_instance_of(Symbol) + :glark.downcase.should.instance_of?(Symbol) end it "converts uppercase ASCII characters to their lowercase equivalents" do diff --git a/spec/ruby/core/symbol/dup_spec.rb b/spec/ruby/core/symbol/dup_spec.rb index 8b35917c27..eef3078030 100644 --- a/spec/ruby/core/symbol/dup_spec.rb +++ b/spec/ruby/core/symbol/dup_spec.rb @@ -2,6 +2,6 @@ require_relative '../../spec_helper' describe "Symbol#dup" do it "returns self" do - :a_symbol.dup.should equal(:a_symbol) + :a_symbol.dup.should.equal?(:a_symbol) end end diff --git a/spec/ruby/core/symbol/empty_spec.rb b/spec/ruby/core/symbol/empty_spec.rb index 19c23cfe5f..1d90a59a5b 100644 --- a/spec/ruby/core/symbol/empty_spec.rb +++ b/spec/ruby/core/symbol/empty_spec.rb @@ -2,10 +2,10 @@ require_relative '../../spec_helper' describe "Symbol#empty?" do it "returns true if self is empty" do - :"".empty?.should be_true + :"".empty?.should == true end it "returns false if self is non-empty" do - :"a".empty?.should be_false + :"a".empty?.should == false end end diff --git a/spec/ruby/core/symbol/inspect_spec.rb b/spec/ruby/core/symbol/inspect_spec.rb index 58402ab261..f2269996af 100644 --- a/spec/ruby/core/symbol/inspect_spec.rb +++ b/spec/ruby/core/symbol/inspect_spec.rb @@ -5,6 +5,8 @@ describe "Symbol#inspect" do fred: ":fred", :fred? => ":fred?", :fred! => ":fred!", + :BAD! => ":BAD!", + :_BAD! => ":_BAD!", :$ruby => ":$ruby", :@ruby => ":@ruby", :@@ruby => ":@@ruby", @@ -64,9 +66,9 @@ describe "Symbol#inspect" do :~ => ":~", :| => ":|", - :"!" => [":\"!\"", ":!" ], - :"!=" => [":\"!=\"", ":!="], - :"!~" => [":\"!~\"", ":!~"], + :"!" => ":!", + :"!=" => ":!=", + :"!~" => ":!~", :"\$" => ":\"$\"", # for justice! :"&&" => ":\"&&\"", :"'" => ":\"\'\"", @@ -94,12 +96,36 @@ describe "Symbol#inspect" do :"foo " => ":\"foo \"", :" foo" => ":\" foo\"", :" " => ":\" \"", + + :"ê" => [":ê", ":\"\\u00EA\""], + :"测" => [":测", ":\"\\u6D4B\""], + :"🦊" => [":🦊", ":\"\\u{1F98A}\""], } + expected_by_encoding = Encoding::default_external == Encoding::UTF_8 ? 0 : 1 symbols.each do |input, expected| - expected = expected[1] if expected.is_a?(Array) + expected = expected[expected_by_encoding] if expected.is_a?(Array) it "returns self as a symbol literal for #{expected}" do input.inspect.should == expected end end + + it "quotes BINARY symbols" do + sym = "foo\xA4".b.to_sym + sym.inspect.should == ':"foo\xA4"' + end + + it "quotes symbols in non-ASCII-compatible encodings" do + Encoding.list.reject(&:ascii_compatible?).reject(&:dummy?).each do |encoding| + sym = "foo".encode(encoding).to_sym + sym.inspect.should == ':"foo"' + end + end + + it "quotes and escapes symbols in dummy encodings" do + Encoding.list.select(&:dummy?).each do |encoding| + sym = "abcd".dup.force_encoding(encoding).to_sym + sym.inspect.should == ':"\x61\x62\x63\x64"' + end + end end diff --git a/spec/ruby/core/symbol/intern_spec.rb b/spec/ruby/core/symbol/intern_spec.rb index ea04b87e8a..9d0914c7fb 100644 --- a/spec/ruby/core/symbol/intern_spec.rb +++ b/spec/ruby/core/symbol/intern_spec.rb @@ -6,6 +6,6 @@ describe "Symbol#intern" do end it "returns a Symbol" do - :foo.intern.should be_kind_of(Symbol) + :foo.intern.should.is_a?(Symbol) end end diff --git a/spec/ruby/core/symbol/match_spec.rb b/spec/ruby/core/symbol/match_spec.rb index 41e058f977..7b165218c6 100644 --- a/spec/ruby/core/symbol/match_spec.rb +++ b/spec/ruby/core/symbol/match_spec.rb @@ -6,7 +6,7 @@ describe :symbol_match, shared: true do end it "returns nil if there is no match" do - :a.send(@method, /b/).should be_nil + :a.send(@method, /b/).should == nil end it "sets the last match pseudo-variables" do @@ -22,12 +22,12 @@ end describe "Symbol#match" do it "returns the MatchData" do result = :abc.match(/b/) - result.should be_kind_of(MatchData) + result.should.is_a?(MatchData) result[0].should == 'b' end it "returns nil if there is no match" do - :a.match(/b/).should be_nil + :a.match(/b/).should == nil end it "sets the last match pseudo-variables" do @@ -38,7 +38,7 @@ describe "Symbol#match" do describe "when passed a block" do it "yields the MatchData" do :abc.match(/./) {|m| ScratchPad.record m } - ScratchPad.recorded.should be_kind_of(MatchData) + ScratchPad.recorded.should.is_a?(MatchData) end it "returns the block result" do @@ -61,17 +61,17 @@ describe "Symbol#match?" do context "when matches the given regex" do it "returns true but does not set Regexp.last_match" do - :string.match?(/string/i).should be_true - Regexp.last_match.should be_nil + :string.match?(/string/i).should == true + Regexp.last_match.should == nil end end it "returns false when does not match the given regex" do - :string.match?(/STRING/).should be_false + :string.match?(/STRING/).should == false end it "takes matching position as the 2nd argument" do - :string.match?(/str/i, 0).should be_true - :string.match?(/str/i, 1).should be_false + :string.match?(/str/i, 0).should == true + :string.match?(/str/i, 1).should == false end end diff --git a/spec/ruby/core/symbol/name_spec.rb b/spec/ruby/core/symbol/name_spec.rb index 15b9aa75e9..f9b631266c 100644 --- a/spec/ruby/core/symbol/name_spec.rb +++ b/spec/ruby/core/symbol/name_spec.rb @@ -1,19 +1,17 @@ require_relative '../../spec_helper' -ruby_version_is "3.0" do - describe "Symbol#name" do - it "returns string" do - :ruby.name.should == "ruby" - :ルビー.name.should == "ルビー" - end +describe "Symbol#name" do + it "returns string" do + :ruby.name.should == "ruby" + :ルビー.name.should == "ルビー" + end - it "returns same string instance" do - :"ruby_3".name.should.equal?(:ruby_3.name) - :"ruby_#{1+2}".name.should.equal?(:ruby_3.name) - end + it "returns same string instance" do + :"ruby_3".name.should.equal?(:ruby_3.name) + :"ruby_#{1+2}".name.should.equal?(:ruby_3.name) + end - it "returns frozen string" do - :symbol.name.should.frozen? - end + it "returns frozen string" do + :symbol.name.should.frozen? end end diff --git a/spec/ruby/core/symbol/shared/id2name.rb b/spec/ruby/core/symbol/shared/id2name.rb index 47f97bd332..00a9c7d7dc 100644 --- a/spec/ruby/core/symbol/shared/id2name.rb +++ b/spec/ruby/core/symbol/shared/id2name.rb @@ -6,4 +6,25 @@ describe :symbol_id2name, shared: true do :@ruby.send(@method).should == "@ruby" :@@ruby.send(@method).should == "@@ruby" end + + it "returns a String in the same encoding as self" do + string = "ruby".encode("US-ASCII") + symbol = string.to_sym + + symbol.send(@method).encoding.should == Encoding::US_ASCII + end + + ruby_version_is "3.4" do + it "warns about mutating returned string" do + -> { :bad!.send(@method).upcase! }.should complain(/warning: string returned by :bad!.to_s will be frozen in the future/) + end + + it "does not warn about mutation when Warning[:deprecated] is false" do + deprecated = Warning[:deprecated] + Warning[:deprecated] = false + -> { :bad!.send(@method).upcase! }.should_not complain + ensure + Warning[:deprecated] = deprecated + end + end end diff --git a/spec/ruby/core/symbol/shared/slice.rb b/spec/ruby/core/symbol/shared/slice.rb index 0df87e183d..4e3a35240c 100644 --- a/spec/ruby/core/symbol/shared/slice.rb +++ b/spec/ruby/core/symbol/shared/slice.rb @@ -7,11 +7,11 @@ describe :symbol_slice, shared: true do end it "returns nil if the index starts from the end and is greater than the length" do - :symbol.send(@method, -10).should be_nil + :symbol.send(@method, -10).should == nil end it "returns nil if the index is greater than the length" do - :symbol.send(@method, 42).should be_nil + :symbol.send(@method, 42).should == nil end end @@ -31,14 +31,14 @@ describe :symbol_slice, shared: true do end it "returns nil if the index is greater than the length" do - :symbol.send(@method, 10,1).should be_nil + :symbol.send(@method, 10,1).should == nil end end describe "and a positive index and negative length" do it "returns nil" do - :symbol.send(@method, 0,-1).should be_nil - :symbol.send(@method, 1,-1).should be_nil + :symbol.send(@method, 0,-1).should == nil + :symbol.send(@method, 1,-1).should == nil end end @@ -56,13 +56,13 @@ describe :symbol_slice, shared: true do end it "returns nil if the index is past the start" do - :symbol.send(@method, -10,1).should be_nil + :symbol.send(@method, -10,1).should == nil end end describe "and a negative index and negative length" do it "returns nil" do - :symbol.send(@method, -1,-1).should be_nil + :symbol.send(@method, -1,-1).should == nil end end @@ -74,21 +74,21 @@ describe :symbol_slice, shared: true do describe "and a nil length" do it "raises a TypeError" do - -> { :symbol.send(@method, 1,nil) }.should raise_error(TypeError) + -> { :symbol.send(@method, 1,nil) }.should.raise(TypeError) end end describe "and a length that cannot be converted into an Integer" do it "raises a TypeError when given an Array" do - -> { :symbol.send(@method, 1,Array.new) }.should raise_error(TypeError) + -> { :symbol.send(@method, 1,Array.new) }.should.raise(TypeError) end it "raises a TypeError when given an Hash" do - -> { :symbol.send(@method, 1,Hash.new) }.should raise_error(TypeError) + -> { :symbol.send(@method, 1,Hash.new) }.should.raise(TypeError) end it "raises a TypeError when given an Object" do - -> { :symbol.send(@method, 1,Object.new) }.should raise_error(TypeError) + -> { :symbol.send(@method, 1,Object.new) }.should.raise(TypeError) end end end @@ -101,21 +101,21 @@ describe :symbol_slice, shared: true do describe "with a nil index" do it "raises a TypeError" do - -> { :symbol.send(@method, nil) }.should raise_error(TypeError) + -> { :symbol.send(@method, nil) }.should.raise(TypeError) end end describe "with an index that cannot be converted into an Integer" do it "raises a TypeError when given an Array" do - -> { :symbol.send(@method, Array.new) }.should raise_error(TypeError) + -> { :symbol.send(@method, Array.new) }.should.raise(TypeError) end it "raises a TypeError when given an Hash" do - -> { :symbol.send(@method, Hash.new) }.should raise_error(TypeError) + -> { :symbol.send(@method, Hash.new) }.should.raise(TypeError) end it "raises a TypeError when given an Object" do - -> { :symbol.send(@method, Object.new) }.should raise_error(TypeError) + -> { :symbol.send(@method, Object.new) }.should.raise(TypeError) end end @@ -136,7 +136,7 @@ describe :symbol_slice, shared: true do describe "that is out of bounds" do it "returns nil if the first range value begins past the end" do - :symbol.send(@method, 10..12).should be_nil + :symbol.send(@method, 10..12).should == nil end it "returns a blank string if the first range value is within bounds and the last range value is not" do @@ -145,11 +145,11 @@ describe :symbol_slice, shared: true do end it "returns nil if the first range value starts from the end and is within bounds and the last value starts from the end and is greater than the length" do - :symbol.send(@method, -10..-12).should be_nil + :symbol.send(@method, -10..-12).should == nil end it "returns nil if the first range value starts from the end and is out of bounds and the last value starts from the end and is less than the length" do - :symbol.send(@method, -10..-2).should be_nil + :symbol.send(@method, -10..-2).should == nil end end @@ -178,7 +178,7 @@ describe :symbol_slice, shared: true do end it "returns nil if the expression does not match" do - :symbol.send(@method, /0-9/).should be_nil + :symbol.send(@method, /0-9/).should == nil end it "sets $~ to the MatchData if there is a match" do @@ -188,7 +188,7 @@ describe :symbol_slice, shared: true do it "does not set $~ if there if there is not a match" do :symbol.send(@method, /[0-9]+/) - $~.should be_nil + $~.should == nil end end @@ -203,8 +203,8 @@ describe :symbol_slice, shared: true do end it "returns nil if there is no capture for the index" do - :symbol.send(@method, /(sy)(mb)(ol)/, 4).should be_nil - :symbol.send(@method, /(sy)(mb)(ol)/, -4).should be_nil + :symbol.send(@method, /(sy)(mb)(ol)/, 4).should == nil + :symbol.send(@method, /(sy)(mb)(ol)/, -4).should == nil end it "converts the index to an Integer" do @@ -213,20 +213,20 @@ describe :symbol_slice, shared: true do describe "and an index that cannot be converted to an Integer" do it "raises a TypeError when given an Hash" do - -> { :symbol.send(@method, /(sy)(mb)(ol)/, Hash.new) }.should raise_error(TypeError) + -> { :symbol.send(@method, /(sy)(mb)(ol)/, Hash.new) }.should.raise(TypeError) end it "raises a TypeError when given an Array" do - -> { :symbol.send(@method, /(sy)(mb)(ol)/, Array.new) }.should raise_error(TypeError) + -> { :symbol.send(@method, /(sy)(mb)(ol)/, Array.new) }.should.raise(TypeError) end it "raises a TypeError when given an Object" do - -> { :symbol.send(@method, /(sy)(mb)(ol)/, Object.new) }.should raise_error(TypeError) + -> { :symbol.send(@method, /(sy)(mb)(ol)/, Object.new) }.should.raise(TypeError) end end it "raises a TypeError if the index is nil" do - -> { :symbol.send(@method, /(sy)(mb)(ol)/, nil) }.should raise_error(TypeError) + -> { :symbol.send(@method, /(sy)(mb)(ol)/, nil) }.should.raise(TypeError) end it "sets $~ to the MatchData if there is a match" do @@ -239,7 +239,7 @@ describe :symbol_slice, shared: true do it "does not set $~ to the MatchData if there is not a match" do :symbol.send(@method, /0-9/, 0) - $~.should be_nil + $~.should == nil end end end @@ -248,7 +248,7 @@ describe :symbol_slice, shared: true do it "does not set $~" do $~ = nil :symbol.send(@method, "sym") - $~.should be_nil + $~.should == nil end it "returns a string if there is match" do @@ -256,7 +256,7 @@ describe :symbol_slice, shared: true do end it "returns nil if there is not a match" do - :symbol.send(@method, "foo").should be_nil + :symbol.send(@method, "foo").should == nil end end end diff --git a/spec/ruby/core/symbol/swapcase_spec.rb b/spec/ruby/core/symbol/swapcase_spec.rb index 24709cac30..95fc29e32b 100644 --- a/spec/ruby/core/symbol/swapcase_spec.rb +++ b/spec/ruby/core/symbol/swapcase_spec.rb @@ -3,7 +3,7 @@ require_relative '../../spec_helper' describe "Symbol#swapcase" do it "returns a Symbol" do - :glark.swapcase.should be_an_instance_of(Symbol) + :glark.swapcase.should.instance_of?(Symbol) end it "converts lowercase ASCII characters to their uppercase equivalents" do diff --git a/spec/ruby/core/symbol/symbol_spec.rb b/spec/ruby/core/symbol/symbol_spec.rb index cefe70bc99..3534686a08 100644 --- a/spec/ruby/core/symbol/symbol_spec.rb +++ b/spec/ruby/core/symbol/symbol_spec.rb @@ -8,12 +8,12 @@ describe "Symbol" do it ".allocate raises a TypeError" do -> do Symbol.allocate - end.should raise_error(TypeError) + end.should.raise(TypeError) end it ".new is undefined" do -> do Symbol.new - end.should raise_error(NoMethodError) + end.should.raise(NoMethodError) end end diff --git a/spec/ruby/core/symbol/to_proc_spec.rb b/spec/ruby/core/symbol/to_proc_spec.rb index 6d9c4bc622..93ed1e9e9b 100644 --- a/spec/ruby/core/symbol/to_proc_spec.rb +++ b/spec/ruby/core/symbol/to_proc_spec.rb @@ -3,7 +3,7 @@ require_relative '../../spec_helper' describe "Symbol#to_proc" do it "returns a new Proc" do proc = :to_s.to_proc - proc.should be_kind_of(Proc) + proc.should.is_a?(Proc) end it "sends self to arguments passed when calling #call on the Proc" do @@ -12,71 +12,50 @@ describe "Symbol#to_proc" do :to_s.to_proc.call(obj).should == "Received #to_s" end - ruby_version_is ""..."3.0" do - it "returns a Proc with #lambda? false" do - pr = :to_s.to_proc - pr.should_not.lambda? - end - - it "produces a Proc with arity -1" do - pr = :to_s.to_proc - pr.arity.should == -1 - end - - it "produces a Proc that always returns [[:rest]] for #parameters" do - pr = :to_s.to_proc - pr.parameters.should == [[:rest]] - end + it "returns a Proc with #lambda? true" do + pr = :to_s.to_proc + pr.should.lambda? end - ruby_version_is "3.0" do - it "returns a Proc with #lambda? true" do - pr = :to_s.to_proc - pr.should.lambda? - end - - it "produces a Proc with arity -2" do - pr = :to_s.to_proc - pr.arity.should == -2 - end + it "produces a Proc with arity -2" do + pr = :to_s.to_proc + pr.arity.should == -2 + end - it "produces a Proc that always returns [[:req], [:rest]] for #parameters" do - pr = :to_s.to_proc - pr.parameters.should == [[:req], [:rest]] - end + it "produces a Proc that always returns [[:req], [:rest]] for #parameters" do + pr = :to_s.to_proc + pr.parameters.should == [[:req], [:rest]] end - ruby_version_is "3.2" do - it "only calls public methods" do - body = proc do - public def pub; @a << :pub end - protected def pro; @a << :pro end - private def pri; @a << :pri end - attr_reader :a - end + it "only calls public methods" do + body = proc do + public def pub; @a << :pub end + protected def pro; @a << :pro end + private def pri; @a << :pri end + attr_reader :a + end - @a = [] - singleton_class.class_eval(&body) - tap(&:pub) - proc{tap(&:pro)}.should raise_error(NoMethodError, /protected method `pro' called/) - proc{tap(&:pri)}.should raise_error(NoMethodError, /private method `pri' called/) - @a.should == [:pub] + @a = [] + singleton_class.class_eval(&body) + tap(&:pub) + proc{tap(&:pro)}.should.raise(NoMethodError, /protected method [`']pro' called/) + proc{tap(&:pri)}.should.raise(NoMethodError, /private method [`']pri' called/) + @a.should == [:pub] - @a = [] - c = Class.new(&body) - o = c.new - o.instance_variable_set(:@a, []) - o.tap(&:pub) - proc{tap(&:pro)}.should raise_error(NoMethodError, /protected method `pro' called/) - proc{o.tap(&:pri)}.should raise_error(NoMethodError, /private method `pri' called/) - o.a.should == [:pub] - end + @a = [] + c = Class.new(&body) + o = c.new + o.instance_variable_set(:@a, []) + o.tap(&:pub) + proc{tap(&:pro)}.should.raise(NoMethodError, /protected method [`']pro' called/) + proc{o.tap(&:pri)}.should.raise(NoMethodError, /private method [`']pri' called/) + o.a.should == [:pub] end it "raises an ArgumentError when calling #call on the Proc without receiver" do -> { :object_id.to_proc.call - }.should raise_error(ArgumentError, /no receiver given|wrong number of arguments \(given 0, expected 1\+\)/) + }.should.raise(ArgumentError, /no receiver given|wrong number of arguments \(given 0, expected 1\+\)/) end it "passes along the block passed to Proc#call" do diff --git a/spec/ruby/core/symbol/upcase_spec.rb b/spec/ruby/core/symbol/upcase_spec.rb index f704bdcbf3..3895d95efb 100644 --- a/spec/ruby/core/symbol/upcase_spec.rb +++ b/spec/ruby/core/symbol/upcase_spec.rb @@ -3,7 +3,7 @@ require_relative '../../spec_helper' describe "Symbol#upcase" do it "returns a Symbol" do - :glark.upcase.should be_an_instance_of(Symbol) + :glark.upcase.should.instance_of?(Symbol) end it "converts lowercase ASCII characters to their uppercase equivalents" do |
