2018-03-04 10:09:32 -05:00
|
|
|
require_relative '../../spec_helper'
|
2017-05-07 08:04:49 -04:00
|
|
|
|
2018-04-28 15:50:06 -04:00
|
|
|
describe 'String#+@' do
|
|
|
|
it 'returns an unfrozen copy of a frozen String' do
|
|
|
|
input = 'foo'.freeze
|
|
|
|
output = +input
|
2017-05-07 08:04:49 -04:00
|
|
|
|
2018-04-28 15:50:06 -04:00
|
|
|
output.frozen?.should == false
|
|
|
|
output.should == 'foo'
|
|
|
|
end
|
2017-05-07 08:04:49 -04:00
|
|
|
|
2018-04-28 15:50:06 -04:00
|
|
|
it 'returns self if the String is not frozen' do
|
|
|
|
input = 'foo'
|
|
|
|
output = +input
|
2017-05-07 08:04:49 -04:00
|
|
|
|
2018-04-28 15:50:06 -04:00
|
|
|
output.equal?(input).should == true
|
|
|
|
end
|
2017-05-07 08:04:49 -04:00
|
|
|
|
2018-04-28 15:50:06 -04:00
|
|
|
it 'returns mutable copy despite freeze-magic-comment in file' do
|
|
|
|
ruby_exe(fixture(__FILE__, "freeze_magic_comment.rb")).should == 'mutable'
|
2017-05-07 08:04:49 -04:00
|
|
|
end
|
|
|
|
end
|