Skip to content

Instantly share code, notes, and snippets.

@JamesDullaghan
Created May 18, 2020 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JamesDullaghan/563656a5f49ed6acc79b897dd6b34480 to your computer and use it in GitHub Desktop.
Save JamesDullaghan/563656a5f49ed6acc79b897dd6b34480 to your computer and use it in GitHub Desktop.
Color Classifier spec example for Carrot
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