spec/spec_helper.rb in earl-report-0.6.2 vs spec/spec_helper.rb in earl-report-0.7.0
- old
+ new
@@ -3,10 +3,11 @@
require "bundler/setup"
require 'rspec'
require 'rspec/its'
require 'amazing_print'
+require 'nokogumbo'
begin
require 'simplecov'
require 'coveralls'
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
@@ -31,6 +32,18 @@
)
::RSpec.configure do |c|
c.filter_run :focus => true
c.run_all_when_everything_filtered = true
+end
+
+RSpec::Matchers.define :be_valid_html do
+ match do |actual|
+ root = Nokogiri::HTML5(actual, max_parse_errors: 1000)
+ @errors = Array(root && root.errors.map(&:to_s))
+ @errors.empty?
+ end
+
+ failure_message do |actual|
+ "expected no errors, was #{@errors.join("\n")}"
+ end
end