-
Notifications
You must be signed in to change notification settings - Fork 1
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 #99 from twingly/read-psl-data-as-utf8
Make sure we always read PSL data as UTF-8
- Loading branch information
Showing
2 changed files
with
34 additions
and
2 deletions.
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,30 @@ | ||
require "spec_helper" | ||
|
||
require "twingly/public_suffix_list" | ||
|
||
describe Twingly::PublicSuffixList do | ||
describe ".with_punycoded_names" do | ||
subject { described_class.with_punycoded_names(encoding: encoding) } | ||
|
||
context "when the list is data is read with the default encoding" do | ||
subject { described_class.with_punycoded_names } | ||
|
||
it { is_expected.to be_a(PublicSuffix::List) } | ||
end | ||
|
||
context "when the list data is read as UTF-8" do | ||
let(:encoding) { Encoding::UTF_8 } | ||
|
||
it { is_expected.to be_a(PublicSuffix::List) } | ||
end | ||
|
||
context "when the list data is read as US-ASCII" do | ||
let(:encoding) { Encoding::US_ASCII } | ||
|
||
it "parsing the data will fail" do | ||
expect { subject }. | ||
to raise_error(ArgumentError, "invalid byte sequence in US-ASCII") | ||
end | ||
end | ||
end | ||
end |