Sha256: 619bca9fcc191eda5dc6b5c9e331dbf6c4efcda03328d0f6d14d95cd6adbc88c

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'

describe Shoes::Swt::ImagePattern do
  let(:dsl)         { Shoes::ImagePattern.new("some/path/to") }
  let(:applied_to)  { double("applied to") }
  let(:swt_image)   { double("swt image") }
  let(:swt_pattern) { double("swt pattern") }

  subject { Shoes::Swt::ImagePattern.new(dsl) }

  it_behaves_like "an swt pattern"

  before do
    allow(::Swt::Image).to receive(:new)   { swt_image }
    allow(::Swt::Pattern).to receive(:new) { swt_pattern }
  end

  describe "#dispose" do
    it "disposes of sub-resources" do
      expect(swt_image).to receive(:dispose)
      expect(swt_pattern).to receive(:dispose)

      expect(subject.pattern).to_not be_nil
      subject.dispose
    end
  end

  describe "#apply_as_stroke" do
    let(:gc) { double("gc") }

    it "sets foreground" do
      expect(gc).to receive(:set_foreground_pattern)
      subject.apply_as_stroke(gc, applied_to)
    end
  end

  describe "#apply_as_fill" do
    let(:gc) { double("gc") }

    it "sets background" do
      expect(gc).to receive(:set_background_pattern)
      subject.apply_as_fill(gc, applied_to)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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