Sha256: 851a29a3c476f5ce70b19e6493325b582d153b740927989025bfb3ed9e361a43

Contents?: true

Size: 1.66 KB

Versions: 47

Compression:

Stored size: 1.66 KB

Contents

describe 'UIColor (CSS)' do

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

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

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

  it "should have a #system_name method" do
    UIColor.whiteColor.system_name.should == :whiteColor
    UIColor.blackColor.system_name.should == :blackColor
    UIColor.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.uicolor
      color.css_name.should == name
    end
  end

  it "should have good to_s return values" do
    UIColor.whiteColor.to_s.should == 'UIColor.whiteColor'
    UIColor.whiteColor.uicolor(0.5).to_s.should == 'UIColor.whiteColor(0.5)'
    :indianred.uicolor.to_s.should == 'UIColor.color(:indianred)'
    :indianred.uicolor(0.5).to_s.should == 'UIColor.color(:indianred, alpha: 0.5)'
    '#12be3f'.uicolor.to_s.should == "UIColor.color('#12be3f')"
    '#12be3f'.uicolor(0.5).to_s.should == "UIColor.color('#12be3f', alpha: 0.5)"
  end

  it "should return UIColor objects" do
    Symbol.uicolors.each do |name, method|
      name.uicolor.should == UIColor.send(method)
    end
    Symbol.css_colors.each do |name, val|
      name.uicolor.is_a?(UIColor).should == true
    end
  end

end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
sugarcube-2.4.0 spec/ios/color_other_representations_spec.rb
sugarcube-2.3.0 spec/ios/color_other_representations_spec.rb
sugarcube-2.2.0 spec/ios/color_other_representations_spec.rb
sugarcube-2.1.5 spec/ios/color_other_representations_spec.rb
sugarcube-2.1.4 spec/ios/color_other_representations_spec.rb
sugarcube-2.1.3 spec/ios/color_other_representations_spec.rb
sugarcube-2.1.2 spec/ios/color_other_representations_spec.rb
sugarcube-2.1.1 spec/ios/color_other_representations_spec.rb
sugarcube-2.1.0 spec/ios/color_other_representations_spec.rb
sugarcube-2.0.2 spec/ios/color_other_representations_spec.rb
sugarcube-2.0.1 spec/ios/color_other_representations_spec.rb
sugarcube-2.0.0 spec/ios/color_other_representations_spec.rb
sugarcube-1.7.0 spec/color_other_representations_spec.rb
sugarcube-1.6.3 spec/color_other_representations_spec.rb
sugarcube-1.6.2 spec/color_other_representations_spec.rb
sugarcube-1.6.1 spec/color_other_representations_spec.rb
sugarcube-1.6.0 spec/color_other_representations_spec.rb
sugarcube-1.5.9 spec/color_other_representations_spec.rb
sugarcube-1.5.8 spec/color_other_representations_spec.rb
sugarcube-1.5.7 spec/color_other_representations_spec.rb