Sha256: e573cfe8e853545b7bff2f86087e71d2be71bf850bbfcb57a46379963b781210

Contents?: true

Size: 967 Bytes

Versions: 2

Compression:

Stored size: 967 Bytes

Contents

require 'spec_helper'

describe HsvConverter do 
  describe ".matches?" do 
    it "should match args with hsv hash" do 
      expect(HsvConverter.matches?(h: 225, s: 73, v: 57)).to be true
    end

    it "should match args with hsb hash" do 
      expect(HsvConverter.matches?(h: 225, s: 73, b: 57)).to be true
    end

    it "should not match args without hsv hash" do 
      expect(HsvConverter.matches?(h: 225, s: 73, l: 57)).to be false
    end
    
    it "should not match a string" do 
      expect(HsvConverter.matches?("#ffffff")).to be false
    end
  end
  
  describe ".rgba" do 
    it "should convert hsv to rgba" do 
      conv = HsvConverter.new(h: 220, s: 75, v: 80)
      rgba = {r: 51, g: 102, b: 204, a: 1.0}
      expect(conv.rgba).to eq rgba
    end

    it "should convert hsb to rgba" do 
      conv = HsvConverter.new(h: 220, s: 75, b: 80)
      rgba = {r: 51, g: 102, b: 204, a: 1.0}
      expect(conv.rgba).to eq rgba
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
color_conversion-0.1.2 spec/converters/hsv_converter_spec.rb
color_conversion-0.1.1 spec/converters/hsv_converter_spec.rb