Sha256: 3528d17411cf07da99896e7b87befded61481e89765acb8483943a956b2cfb3d

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'

describe Shoes::Swt::ColorFactory do
  let(:blue)     { Shoes::COLORS[:blue] }
  let(:gradient) { Shoes::Gradient.new(blue, blue) }

  subject(:factory) { Shoes::Swt::ColorFactory.new }

  it "turns Shoes::Color's into Shoes::Swt::Color's" do
    expect(factory.create(blue)).to_not be_nil
  end

  it "hands back nil for nil" do
    expect(factory.create(nil)).to be_nil
  end

  it "caches colors" do
    first  = factory.create(blue)
    second = factory.create(blue)

    expect(first).to eql(second)
  end

  it "disposes of colors" do
    color = factory.create(blue)
    expect(color).to receive(:dispose)

    factory.dispose
  end

  it "doesn't cache colors across dispose" do
    color = factory.create(blue)
    factory.dispose

    new_color = factory.create(blue)
    expect(color).to_not eql(new_color)
  end

  it "allows gradients through" do
    expect(factory.create(gradient)).to_not be_nil
  end

  it "safely disposes of non-disposable elements" do
    factory.create(gradient)
    expect(gradient).to receive(:dispose).never

    factory.dispose
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
shoes-swt-4.0.0.pre7 spec/shoes/swt/color_factory_spec.rb
shoes-swt-4.0.0.pre6 spec/shoes/swt/color_factory_spec.rb
shoes-swt-4.0.0.pre5 spec/shoes/swt/color_factory_spec.rb