Use if instead of skip to skip tests

This way the tests won't appear as "pending" when running the test
suite, and so we get rid of a lot of noise in the test results. There
doesn't seem to be a way to call `skip` without the test being marked as
"pending".

Note that in the globalizable tests we need to build a factory before
deciding whether an atribute is required or not (particularly for the
milestone factory, since milestone attributes are required depending on
the presence of other attributes). This isn't possible before we're
inside the test, so we can't add an `if:` condition to the test. So
we're adding the condition inside the test instead. A minor
inconvenience of this method is the test still runs even when the
condition is `false`.
This commit is contained in:
Javi Martín
2021-09-08 03:24:15 +02:00
parent 2927174e06
commit e49c32638d
7 changed files with 57 additions and 91 deletions

View File

@@ -167,11 +167,8 @@ describe "Admin poll questions", :admin do
options: ["Seleccionar votación", poll.name_es])
end
scenario "uses fallback if name is not translated to current locale" do
unless globalize_french_fallbacks.first == :es
skip("Spec only useful when French falls back to Spanish")
end
scenario "uses fallback if name is not translated to current locale",
if: Globalize.fallbacks(:fr).reject { |locale| locale.match(/fr/) }.first == :es do
poll = create(:poll, name_en: "Name in English", name_es: "Nombre en Español")
proposal = create(:proposal)
@@ -186,8 +183,4 @@ describe "Admin poll questions", :admin do
options: ["Sélectionner un vote", poll.name_es])
end
end
def globalize_french_fallbacks
Globalize.fallbacks(:fr).reject { |locale| locale.match(/fr/) }
end
end