2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2018-03-28 05:33:41 +00:00
|
|
|
# taken from https://makandracards.com/makandra/1080-rspec-matcher-to-check-if-an-activerecord-exists-in-the-database
|
|
|
|
RSpec::Matchers.define :exist_in_database do
|
|
|
|
|
|
|
|
match do |actual|
|
|
|
|
actual.class.exists?(actual.id)
|
|
|
|
end
|
|
|
|
end
|
2021-09-27 12:28:53 +00:00
|
|
|
|
|
|
|
RSpec::Matchers.define :have_computed_style do
|
|
|
|
|
|
|
|
match do
|
|
|
|
actual_value == expected_value
|
|
|
|
end
|
|
|
|
|
|
|
|
failure_message do
|
|
|
|
"Expected element to have CSS property #{expected_key} with value #{expected_value}. But it was #{actual_value}."
|
|
|
|
end
|
|
|
|
|
|
|
|
def expected_key
|
|
|
|
expected[0]
|
|
|
|
end
|
|
|
|
|
|
|
|
def expected_value
|
|
|
|
expected[1]
|
|
|
|
end
|
|
|
|
|
|
|
|
def actual_value
|
|
|
|
actual.evaluate_script "getComputedStyle(this).#{expected_key}"
|
|
|
|
end
|
|
|
|
end
|