Last active
October 11, 2019 16:43
-
-
Save nathan-appere/40603bd71ba6756df94432b740c404e2 to your computer and use it in GitHub Desktop.
Revisions
-
nathan-appere revised this gist
Oct 11, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -18,5 +18,5 @@ def self.rgb_to_hex(r:, g:, b:) #RuntimeError: # Kit::Contracts | after failure for `Test::RGB.rgb_to_hex` # ["/Users/nathan/bootcamp/elearning/code/kit/libs/kit-organizer/spec/rgb_spec.rb", 11] ->(result:) { result.start_with?('#') }, # Called with: {:result=>"+80200c"} -
nathan-appere created this gist
Oct 11, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ module Test module RGB include Kit::Contract before ->(r:, g:, b:) { (0..255) === r && (0..255) === g && (0..255) === b } after [ ->(result:) { result.is_a?(String) }, ->(result:) { result.start_with?('#') }, ->(result:) { result.length.in?([4, 7]) }, ] def self.rgb_to_hex(r:, g:, b:) "+" << [r, g, b].map { |el| el.to_s(16).rjust(2, '0') }.join end end end Test::RGB.rgb_to_hex(r: 128, g: 32, b: 12) #RuntimeError: # Kit::Contracts | after failure for `Test::RGB.rgb_to_hex` # ["/Users/nathan/bootcamp/elearning/code/kit/libs/kit-organizer/spec/rgb_spec.rb", 13] ->(result:) { result.start_with?('#') }, # {:result=>"+80200c"}