-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #117 from localshred/bj/fix_frozen_string_encode
Dup string value when encoding if it is frozen
- Loading branch information
Showing
4 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require 'spec_helper' | ||
|
||
describe ::Protobuf::Field::StringField do | ||
describe '#encode' do | ||
context 'when a repeated string field contains frozen strings' do | ||
it 'does not raise an encoding error' do | ||
expect { | ||
frozen_strings = [ "foo".freeze, "bar".freeze, "baz".freeze ] | ||
::Test::ResourceFindRequest.encode(:name => 'resource', :widgets => frozen_strings) | ||
}.not_to raise_error | ||
end | ||
end | ||
|
||
context 'when a repeated bytes field contains frozen strings' do | ||
it 'does not raise an encoding error' do | ||
expect { | ||
frozen_strings = [ "foo".freeze, "bar".freeze, "baz".freeze ] | ||
::Test::ResourceFindRequest.encode(:name => 'resource', :widget_bytes => frozen_strings) | ||
}.not_to raise_error | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters