Skip to content

Commit a1d2758

Browse files
committed
fix matchers
1 parent 47bf567 commit a1d2758

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

spec/spec_helper.rb

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222

2323
# Start SimpleCov
2424
SimpleCov.start do
25-
formatter SimpleCov::Formatter::MultiFormatter.new([SimpleCov::Formatter::HTMLFormatter, SimpleCov::Formatter::JSONFormatter])
25+
formatter SimpleCov::Formatter::MultiFormatter.new([SimpleCov::Formatter::HTMLFormatter,
26+
SimpleCov::Formatter::JSONFormatter])
2627
add_filter 'spec/'
2728
end
2829

@@ -134,6 +135,21 @@ def setup_items(container) # rubocop:disable Metrics/AbcSize
134135
end
135136
end
136137

138+
RSpec::Matchers.define :have_no_css do |expected|
139+
match do |actual|
140+
selector = Nokogiri::HTML(actual).css(expected)
141+
expect(selector.size).to eq 0
142+
end
143+
144+
failure_message do |actual|
145+
"expected #{actual} to have no elements matching '#{expected}'"
146+
end
147+
148+
failure_message_when_negated do |actual|
149+
"expected #{actual} to have elements matching '#{expected}'"
150+
end
151+
end
152+
137153
# Configure RSpec with Rails
138154
begin
139155
require 'rails'

0 commit comments

Comments
 (0)