Sha256: 33cb9cc7e0be7659851380fed9c7d665108f485a75e51bba8a98ac24fd365224

Contents?: true

Size: 911 Bytes

Versions: 2

Compression:

Stored size: 911 Bytes

Contents

require 'spec_helper'

describe HslStringConverter do 
  describe ".matches?" do 
    it "should match args with hsl string" do 
      expect(HslStringConverter.matches?("hsl(225, 73%, 57%)")).to be true
    end

    it "should match args with hsla string" do 
      expect(HslStringConverter.matches?("hsla(225, 73%, 57%, 0.5)")).to be true
    end

    it "should not match args without hsl string" do 
      expect(HslStringConverter.matches?(h: 225, s: 73, l: 57)).to be false
    end
  end
  
  describe ".rgba" do 
    it "should convert hsl to rgba" do 
      conv = HslStringConverter.new("hsl(225, 73%, 57%)")
      rgba = {r: 65, g: 105, b: 225, a: 1.0}
      expect(conv.rgba).to eq rgba
    end

    it "should convert hsla to rgba" do 
      conv = HslStringConverter.new("hsla(225, 73%, 57%, 0.5)")
      rgba = {r: 65, g: 105, b: 225, a: 0.5}
      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/hsl_string_converter_spec.rb
color_conversion-0.1.1 spec/converters/hsl_string_converter_spec.rb