Created
May 18, 2020 21:19
-
-
Save JamesDullaghan/563656a5f49ed6acc79b897dd6b34480 to your computer and use it in GitHub Desktop.
Color Classifier spec example for Carrot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
::LIGHT_COLORS = %i[ | |
#800000 | |
#ff0000 | |
#800080 | |
#ff00ff | |
#008000 | |
#00ff00 | |
#808000 | |
#ffff00 | |
#000080 | |
#0000ff | |
#008080 | |
#00ffff | |
] | |
::GRAYSCALE_COLORS = %i[ | |
#000000 | |
#c0c0c0 | |
#808080 | |
#ffffff | |
] | |
describe ColorClassifier do | |
subject { described_class.new(attributes) } | |
describe '#grayscale?' do | |
::LIGHT_COLORS.each do |color| | |
context "when #{color}" do | |
let(:attributes) { { hex_code: color } } | |
it 'returns false' do | |
expect(subject.grayscale?).to eq false | |
end | |
end | |
end | |
::GRAYSCALE_COLORS.each do |color| | |
context "when #{color}" do | |
let(:attributes) { { hex_code: color } } | |
it 'returns true' do | |
expect(subject.grayscale?).to eq true | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment