Skip to content

Commit

Permalink
Bring in ice_nine as a test dependency and implement tests using it
Browse files Browse the repository at this point in the history
to ensure there are no unnecessary mutations in uri_spec.rb
  • Loading branch information
ACBullen committed Apr 24, 2019
1 parent a57778a commit 5b65b93
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -5,6 +5,7 @@ gemspec
group :test do
gem 'rspec', '~> 3.5'
gem 'rspec-its', '~> 1.1'
gem 'ice_nine', '~> 0.11'
end

group :development do
Expand Down
63 changes: 63 additions & 0 deletions spec/addressable/uri_spec.rb
Expand Up @@ -21,6 +21,8 @@
require "addressable/uri"
require "uri"
require "ipaddr"
require "ice_nine"
require "ice_nine/core_ext/object"

if !"".respond_to?("force_encoding")
class String
Expand Down Expand Up @@ -999,6 +1001,67 @@ def to_s
end
end

describe Addressable::URI, "when normalized and then deeply frozen" do
before do
@uri = Addressable::URI.parse(
"http://user:password@example.com:8080/path?query=value#fragment"
).normalize!.deep_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
p @uri.normalized_userinfo
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(FrozenError)
end
end

describe Addressable::URI, "when created from string components" do
before do
@uri = Addressable::URI.new(
Expand Down

0 comments on commit 5b65b93

Please sign in to comment.