Sha256: 556d108d288c15df5daee37a4807a6905c6c4dd041c966c2c098561ab5bdc7ad

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

require 'shoes/swt/spec_helper'

describe Shoes::Swt::Common::Remove do
  let(:clazz)  {
    Class.new do
      include Shoes::Swt::Common::Remove

      attr_reader :app, :real, :dsl

      def initialize(app, dsl, real = nil)
        @app = app
        @dsl = dsl
        @real = real
      end
    end
  }

  let(:app)  { double("app", click_listener: click_listener) }
  let(:dsl)  { double("dsl") }
  let(:click_listener) { double("click listener") }

  subject { clazz.new(app, dsl) }

  before do
    expect(app).to receive(:remove_paint_listener)
    expect(click_listener).to receive(:remove_listeners_for).at_least(:once)
  end

  describe "real disposal" do
    let(:real) { double("real") }

    subject { clazz.new(app, dsl, real) }

    it "disposes of real if present" do
      allow(real).to receive(:disposed?) { false }
      expect(real).to receive(:dispose)
      subject.remove
    end

    it "doesn't dispose if already done!" do
      allow(real).to receive(:disposed?) { true }
      expect(real).to_not receive(:dispose)
      subject.remove
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shoes-swt-4.0.0.pre4 spec/shoes/swt/common/remove_spec.rb
shoes-swt-4.0.0.pre3 spec/shoes/swt/common/remove_spec.rb