-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c87ba28
commit 5b92119
Showing
12 changed files
with
413 additions
and
1,505 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe IndieWeb::Endpoints::Client, '#endpoints' do | ||
# TODO: Rework these specs to use WebMock: https://github.com/bblimke/webmock | ||
context 'when running the webmention.rocks Endpoint Discovery tests' do | ||
WebmentionRocks::ENDPOINT_DISCOVERY_TESTS.each do |url, regexp| | ||
describe url do | ||
subject { described_class.new(url).endpoints[:webmention] } | ||
|
||
it { is_expected.to match(regexp) } | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe IndieWeb::Endpoints::Client, '#inspect' do | ||
subject { described_class.new('https://example.com').inspect } | ||
|
||
it { is_expected.to match(/^#<#{described_class}:0x[a-f0-9]+ uri: ".*">$/) } | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe IndieWeb::Endpoints::Client, '#response' do | ||
let(:url) { 'https://example.com' } | ||
|
||
let(:client) { described_class.new(url) } | ||
let(:request) { stub_request(:get, url) } | ||
|
||
context 'when rescuing an HTTP::ConnectionError' do | ||
before do | ||
request.to_raise(HTTP::ConnectionError) | ||
end | ||
|
||
it 'raises an HttpError' do | ||
expect { client.response }.to raise_error(IndieWeb::Endpoints::HttpError) | ||
end | ||
end | ||
|
||
context 'when rescuing an HTTP::TimeoutError' do | ||
before do | ||
request.to_raise(HTTP::TimeoutError) | ||
end | ||
|
||
it 'raises an HttpError' do | ||
expect { client.response }.to raise_error(IndieWeb::Endpoints::HttpError) | ||
end | ||
end | ||
|
||
context 'when rescuing an HTTP::Redirector::TooManyRedirectsError' do | ||
before do | ||
request.to_raise(HTTP::Redirector::TooManyRedirectsError) | ||
end | ||
subject(:response) { described_class.new(url).response } | ||
|
||
it 'raises an HttpError' do | ||
expect { client.response }.to raise_error(IndieWeb::Endpoints::HttpError) | ||
end | ||
end | ||
|
||
context 'when given an invalid URL' do | ||
let(:url) { 'http:' } | ||
|
||
it 'raises an InvalidURIError' do | ||
expect { client.response }.to raise_error(IndieWeb::Endpoints::InvalidURIError) | ||
end | ||
end | ||
|
||
context 'when given a relative URL' do | ||
let(:url) { '../foo/bar/biz/baz' } | ||
|
||
it 'raises an HttpError' do | ||
message = 'unknown scheme: ' | ||
|
||
expect { client.response }.to raise_error(IndieWeb::Endpoints::HttpError, message) | ||
end | ||
end | ||
|
||
context 'when given a URL with an invalid protocol' do | ||
let(:url) { 'file:///foo/bar/baz' } | ||
let(:url) { 'https://example.com' } | ||
|
||
it 'raises an HttpError' do | ||
message = 'unknown scheme: file' | ||
context 'when rescuing from an HTTP::Error' do | ||
it 'raises an IndieWeb::Endpoints::HttpError' do | ||
stub_request(:get, url).to_raise(HTTP::Error) | ||
|
||
expect { client.response }.to raise_error(IndieWeb::Endpoints::HttpError, message) | ||
expect { response }.to raise_error(IndieWeb::Endpoints::HttpError) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe IndieWeb::Endpoints::Client do | ||
context 'when not given a String-like object' do | ||
it 'raises a NoMethodError' do | ||
expect { described_class.new(nil) }.to raise_error(NoMethodError) | ||
subject(:client) { described_class.new(url) } | ||
|
||
context 'when given invalid arguments' do | ||
let(:url) { '1:' } | ||
|
||
it 'raises an IndieWeb::Endpoints::InvalidURIError' do | ||
expect { client }.to raise_error(IndieWeb::Endpoints::InvalidURIError) | ||
end | ||
end | ||
end |
281 changes: 0 additions & 281 deletions
281
spec/lib/indieweb/endpoints/parsers/authorization_endpoint_parser_spec.rb
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.