Skip to content

Commit ed496d4

Browse files
committed
Add a missing spec for String interpolation with class variables
1 parent 7ce927f commit ed496d4

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module StringSpecs
2+
class ClassWithClassVariable
3+
@@a = "xxx"
4+
5+
def foo
6+
"#@@a"
7+
end
8+
end
9+
end

spec/ruby/language/string_spec.rb

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- encoding: binary -*-
22

33
require_relative '../spec_helper'
4+
require_relative 'fixtures/class_with_class_variable'
45

56
# TODO: rewrite these horrid specs. it "are..." seriously?!
67

@@ -27,6 +28,11 @@
2728
"#$ip".should == 'xxx'
2829
end
2930

31+
it "interpolate class variables just with the # character" do
32+
object = StringSpecs::ClassWithClassVariable.new
33+
object.foo.should == 'xxx'
34+
end
35+
3036
it "allows underscore as part of a variable name in a simple interpolation" do
3137
@my_ip = 'xxx'
3238
"#@my_ip".should == 'xxx'
@@ -280,15 +286,15 @@ def long_string_literals
280286

281287
it "creates a non-frozen String" do
282288
code = <<~'RUBY'
283-
"a#{6*7}c"
289+
"a#{6*7}c"
284290
RUBY
285291
eval(code).should_not.frozen?
286292
end
287293

288294
it "creates a non-frozen String when # frozen-string-literal: true is used" do
289295
code = <<~'RUBY'
290-
# frozen-string-literal: true
291-
"a#{6*7}c"
296+
# frozen-string-literal: true
297+
"a#{6*7}c"
292298
RUBY
293299
eval(code).should_not.frozen?
294300
end

0 commit comments

Comments
 (0)