-
Notifications
You must be signed in to change notification settings - Fork 268
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Force UTF-8 encoding only if needed (#341)
Co-authored-by: Philip Ross <[email protected]> Co-authored-by: Philip Ross <[email protected]> Co-authored-by: Bob Aman <[email protected]>
- Loading branch information
1 parent
99810af
commit 860fede
Showing
2 changed files
with
86 additions
and
20 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 |
---|---|---|
|
@@ -998,6 +998,72 @@ def to_s | |
end | ||
end | ||
|
||
describe Addressable::URI, "when normalized and then deeply frozen" do | ||
before do | ||
@uri = Addressable::URI.parse( | ||
"http://user:[email protected]:8080/path?query=value#fragment" | ||
).normalize! | ||
|
||
@uri.instance_variables.each do |var| | ||
@uri.instance_variable_set(var, @uri.instance_variable_get(var).freeze) | ||
end | ||
|
||
@uri.freeze | ||
end | ||
|
||
it "#normalized_scheme should not error" do | ||
expect { @uri.normalized_scheme }.not_to raise_error | ||
end | ||
|
||
it "#normalized_user should not error" do | ||
expect { @uri.normalized_user }.not_to raise_error | ||
end | ||
|
||
it "#normalized_password should not error" do | ||
expect { @uri.normalized_password }.not_to raise_error | ||
end | ||
|
||
it "#normalized_userinfo should not error" do | ||
expect { @uri.normalized_userinfo }.not_to raise_error | ||
end | ||
|
||
it "#normalized_host should not error" do | ||
expect { @uri.normalized_host }.not_to raise_error | ||
end | ||
|
||
it "#normalized_authority should not error" do | ||
expect { @uri.normalized_authority }.not_to raise_error | ||
end | ||
|
||
it "#normalized_port should not error" do | ||
expect { @uri.normalized_port }.not_to raise_error | ||
end | ||
|
||
it "#normalized_site should not error" do | ||
expect { @uri.normalized_site }.not_to raise_error | ||
end | ||
|
||
it "#normalized_path should not error" do | ||
expect { @uri.normalized_path }.not_to raise_error | ||
end | ||
|
||
it "#normalized_query should not error" do | ||
expect { @uri.normalized_query }.not_to raise_error | ||
end | ||
|
||
it "#normalized_fragment should not error" do | ||
expect { @uri.normalized_fragment }.not_to raise_error | ||
end | ||
|
||
it "should be frozen" do | ||
expect(@uri).to be_frozen | ||
end | ||
|
||
it "should not allow destructive operations" do | ||
expect { @uri.normalize! }.to raise_error(RuntimeError) | ||
end | ||
end | ||
|
||
describe Addressable::URI, "when created from string components" do | ||
before do | ||
@uri = Addressable::URI.new( | ||
|