describe "The landing page" do
it "has a footer element that has a dark blue background color.", {:js => true, :points => 1} do
visit "/"
footer = find("footer")
rgba_color_value = footer.native.style("background-color")
color_number_values = rgba_color_value.gsub(/rgba?\(/, "").split(",")
red_value = color_number_values.first.to_i
green_value = color_number_values.second.to_i
blue_value = color_number_values.third.to_i
if blue_value > green_value && blue_value > red_value
expect(green_value).to be < blue_value,
"Expected the amount of Green(#{green_value}) in the color of the link to be less than the amount of Blue(#{blue_value}), but wasn't."
expect(red_value).to be < blue_value,
"Expected the amount of Red(#{red_value}) in the color of the link to be less than the amount of Blue(#{blue_value}), but wasn't."
else
descendent_divs = all("footer div")
descendent_divs.each_with_index do |div, index|
rgba_color_value = div.native.style("background-color")
color_number_values = rgba_color_value.gsub(/rgba?\(/, "").split(",")
red_value = color_number_values.first.to_i
green_value = color_number_values.second.to_i
blue_value = color_number_values.third.to_i
if blue_value > green_value && blue_value > red_value
expect(green_value).to be < blue_value,
"Expected the amount of Green(#{green_value}) in the color of the link to be less than the amount of Blue(#{blue_value}), but wasn't."
expect(red_value).to be < blue_value,
"Expected the amount of Red(#{red_value}) in the color of the link to be less than the amount of Blue(#{blue_value}), but wasn't."
break
elsif index == (descendent_divs.count - 1)
expect(green_value).to be < blue_value,
"Expected the amount of Green(#{green_value}) in the color of the link to be less than the amount of Blue(#{blue_value}), but wasn't."
expect(red_value).to be < blue_value,
"Expected the amount of Red(#{red_value}) in the color of the link to be less than the amount of Blue(#{blue_value}), but wasn't."
end
end
end
end
end
Created
April 18, 2020 23:57
-
-
Save jelaniwoods/0a4bffc2aeb712e6d095b2719f5c5dc2 to your computer and use it in GitHub Desktop.