Sha256: 6a83531d8ecbbd3b04e6f148b91796c81079431d1ed2e14739d8d4d673611006

Contents?: true

Size: 1.8 KB

Versions: 41

Compression:

Stored size: 1.8 KB

Contents

describe 'NSColor, other representations' do

  it "should have a #to_i method" do
    NSColor.whiteColor.to_i.should == 16777215
    NSColor.blackColor.to_i.should == 0
  end

  it "should have a #to_a method" do
    NSColor.whiteColor.to_a.should == [255, 255, 255]
    NSColor.blackColor.to_a.should == [0, 0, 0]
  end

  it "should have a #hex method" do
    NSColor.whiteColor.hex.should == '#ffffff'
    NSColor.blackColor.hex.should == '#000000'
  end

  it "should have a #system_name method" do
    NSColor.whiteColor.system_name.should == :whiteColor
    NSColor.blackColor.system_name.should == :blackColor
    NSColor.lightGrayColor.system_name.should == :lightGrayColor
  end

  it "should return css color names" do
    corrections = {
      aqua: :cyan,
      lime: :green,
      fuchsia: :magenta,
    }
    Symbol.css_colors.each do |name, val|
      name = corrections.fetch(name, name)

      color = val.nscolor
      color.css_name.should == name
    end
  end

  it "should have good to_s return values" do
    NSColor.whiteColor.to_s.should == 'NSColor.whiteColor'
    NSColor.whiteColor.nscolor(0.5).to_s.should == 'NSColor.whiteColor.colorWithAlphaComponent(0.5)'
    :indianred.nscolor.to_s.should == ':indianred.nscolor'
    :indianred.nscolor(0.5).to_s.should == ':indianred.nscolor(0.5)'
    '#12be3f'.nscolor.to_s.should == "'#12be3f'.nscolor"
    '#12be3f'.nscolor(0.5).to_s.should == "'#12be3f'.nscolor(0.5)"
  end

  describe 'System colors' do
    Symbol.nscolors.each do |name, method|
      it "should support #{name.inspect}.nscolor" do
        name.nscolor.should.be.kind_of(NSColor)
      end
    end
  end

  describe 'CSS names' do
    Symbol.css_colors.each do |name, val|
      it "should support #{name.inspect}.nscolor" do
        name.nscolor.should.be.kind_of(NSColor)
      end
    end
  end

end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
sugarcube-3.0.4 spec/osx/color_other_representations_spec.rb
sugarcube-3.0.3 spec/osx/color_other_representations_spec.rb
sugarcube-3.0.2 spec/osx/color_other_representations_spec.rb
sugarcube-3.0.1 spec/osx/color_other_representations_spec.rb
sugarcube-3.0.0 spec/osx/color_other_representations_spec.rb
sugarcube-2.12.3 spec/osx/color_other_representations_spec.rb
sugarcube-2.12.2 spec/osx/color_other_representations_spec.rb
sugarcube-2.12.1 spec/osx/color_other_representations_spec.rb
sugarcube-2.12.0 spec/osx/color_other_representations_spec.rb
sugarcube-2.11.1 spec/osx/color_other_representations_spec.rb
sugarcube-2.11.0 spec/osx/color_other_representations_spec.rb
sugarcube-2.10.0 spec/osx/color_other_representations_spec.rb
sugarcube-2.9.1 spec/osx/color_other_representations_spec.rb
sugarcube-2.8.2 spec/osx/color_other_representations_spec.rb
sugarcube-2.8.1 spec/osx/color_other_representations_spec.rb
sugarcube-2.8.0 spec/osx/color_other_representations_spec.rb
sugarcube-2.7.1 spec/osx/color_other_representations_spec.rb
sugarcube-2.7.0 spec/osx/color_other_representations_spec.rb
sugarcube-2.6.0 spec/osx/color_other_representations_spec.rb
sugarcube-2.5.0 spec/osx/color_other_representations_spec.rb