Sha256: 0aa4fea1c00cddf690621d8b17e6f3b324d8143c7bc7c64da99ab912cff71bf5

Contents?: true

Size: 887 Bytes

Versions: 1

Compression:

Stored size: 887 Bytes

Contents

require 'spec_helper'

describe HexConverter do 
  describe ".matches?" do 
    it "should match args with hex string" do 
      expect(HexConverter.matches?("#FFFFFF")).to be_true
    end

    it "should match args with short hex string" do 
      expect(HexConverter.matches?("#FFF")).to be_true
    end

    it "should match args with lower case hex string" do 
      expect(HexConverter.matches?("#ffffff")).to be_true
    end

    it "should not match args without hex string" do 
      expect(HexConverter.matches?("asdf")).to be_false
    end

    it "should not match args without hex string" do 
      expect(HexConverter.matches?(h: 225, s: 73, l: 57)).to be_false
    end
  end

  describe ".rgba" do 
    it "should convert to rgba" do 
      conv = HexConverter.new("#3366cc")
      rgba = {r: 51, g: 102, b: 204, a: 1.0}
      expect(conv.rgba).to eq rgba
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
color_conversion-0.1.0 spec/converters/hex_converter_spec.rb