Note we're excluding a few files: * Configuration files that weren't generated by us * Migration files that weren't generated by us * The Gemfile, since it includes an important comment that must be on the same line as the gem declaration * The Budget::Stats class, since the heading statistics are a mess and having shorter lines would require a lot of refactoring
27 lines
790 B
Ruby
27 lines
790 B
Ruby
RSpec::Matchers.define :be_rendered do |with: nil|
|
|
match do |page|
|
|
if with.nil?
|
|
!page.native.inner_html.empty?
|
|
else
|
|
page.has_css?("body") && page.find("body").native.inner_html == with
|
|
end
|
|
end
|
|
|
|
failure_message do |page|
|
|
if page.has_css?("body")
|
|
"expected page to be rendered with #{with}, " \
|
|
"but was rendered with #{page.find("body").native.inner_html}"
|
|
else
|
|
"expected page to be rendered with #{with}, but was not rendered"
|
|
end
|
|
end
|
|
|
|
failure_message_when_negated do |page|
|
|
if page.has_css?("body")
|
|
"expected page not to be rendered, but was rendered with #{page.find("body").native.inner_html}"
|
|
else
|
|
"expected page not to be rendered, but was rendered with #{page.native.inner_html}"
|
|
end
|
|
end
|
|
end
|