Skip to content

Commit

Permalink
Add expectation per discussion; add an existing char to split on
Browse files Browse the repository at this point in the history
  • Loading branch information
bf4 committed Jan 15, 2015
1 parent 9a13068 commit 9eeedb9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions spec/rspec/support/encoded_string_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ module RSpec::Support

describe '#split' do
context 'when there is an undefined conversion to the target encoding' do
let(:wrapped_string) { "aaaaaaaaaaa#{ascii_arrow_symbol}aaaaa".force_encoding("ASCII-8BIT") }
let(:wrapped_string_template) { "abaaaaaaaaaa%saaaaa" }
let(:wrapped_string) { sprintf(wrapped_string_template, ascii_arrow_symbol).force_encoding("ASCII-8BIT") }

it 'normally raises an Encoding::UndefinedConversionError' do
expect {
Expand All @@ -183,9 +184,14 @@ module RSpec::Support
end

it 'splits the string based on the delimiter accounting for encoding' do
expect {
build_encoded_string(wrapped_string, utf8_encoding).split(utf_8_euro_symbol.force_encoding("UTF-8"))
}.not_to raise_error
delimiter = "b".force_encoding(utf8_encoding)
resulting_string = build_encoded_string(wrapped_string, utf8_encoding).
split(delimiter)
exp1, exp2 = sprintf(wrapped_string_template, EncodedString::REPLACE).force_encoding(utf8_encoding).split(delimiter)
expect(resulting_string).to match [
a_string_identical_to(exp1),
a_string_identical_to(exp2)
]
end
end

Expand Down

0 comments on commit 9eeedb9

Please sign in to comment.