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
426e8c3
commit 5515369
Showing
2 changed files
with
52 additions
and
5 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,33 @@ | ||
require 'spec_helper' | ||
|
||
describe 'Middleware test' do | ||
let(:request) {{"REQUEST_METHOD" => "GET"}} | ||
let(:response) { File.open(response_fixture) } | ||
let(:app) { Proc.new {|*args| [200, {}, response] }} | ||
let(:middleware) { HTMLProofer::Middleware.new(app) } | ||
subject { middleware.call(request) } | ||
|
||
context 'with invalid HTML' do | ||
let(:response_fixture) { File.join(FIXTURES_DIR, 'html', 'missing_closing_quotes.html') } | ||
it 'raises an error' do | ||
expect { | ||
subject | ||
}.to raise_error(HTMLProofer::Middleware::InvalidHtmlError) | ||
end | ||
end | ||
|
||
context 'with valid HTML' do | ||
let(:response_fixture) { File.join(FIXTURES_DIR, 'html', 'html5_tags.html') } | ||
it 'does not raise an error' do | ||
subject | ||
end | ||
end | ||
|
||
context 'with non-HTML content' do | ||
let(:response_fixture) { File.join(FIXTURES_DIR, 'images', 'gpl.png') } | ||
it 'does not raise an error' do | ||
subject | ||
end | ||
end | ||
|
||
end |