Sha256: cae548004714469fc4dcca873d5a7f9930d5fb5d0bc053bd0db4886fd0ae7959

Contents?: true

Size: 920 Bytes

Versions: 2

Compression:

Stored size: 920 Bytes

Contents

require File.expand_path('../fixtures/classes', __FILE__)

describe "Observer#count_observers" do
  before(:each) do
    @observable = ObservableSpecs.new
    @observer   = ObserverCallbackSpecs.new
    @observer2  = ObserverCallbackSpecs.new
  end

  it "returns the number of observers" do
    @observable.count_observers.should == 0
    @observable.add_observer(@observer)
    @observable.count_observers.should == 1
    @observable.add_observer(@observer2)
    @observable.count_observers.should == 2
  end

  ruby_version_is "" ... "1.9" do
    it "returns the number observers including duplicates" do
      2.times { @observable.add_observer(@observer) }
      @observable.count_observers.should == 2
    end
  end

  ruby_version_is "1.9" do
    it "returns the number of unique observers" do
      2.times { @observable.add_observer(@observer) }
      @observable.count_observers.should == 1
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubysl-observer-1.0.0 spec/count_observers_spec.rb
rubysl-observer-2.0.0 spec/count_observers_spec.rb