Sha256: 506937dfd4344ed5630609bd0aba30f3af084874fa9b2062639776aba513ceeb

Contents?: true

Size: 1008 Bytes

Versions: 17

Compression:

Stored size: 1008 Bytes

Contents

describe "NSNotificationCenter" do
  SampleNotification = "SampleNotification"

  after do
    @observer = nil
  end
  
  after do
    BW::App.notification_center.unobserve(@observer) if @observer
  end

  it "return notification center" do
    BW::App.notification_center.should.not.be.nil
  end

  it "add observer" do
    notified = false
    @observer = BW::App.notification_center.observe(SampleNotification) do |note|
      notified = true
      note.should.is_a NSNotification
      note.object.class.should == Time
      note.userInfo.should.not.be.nil
      note.userInfo[:status].should == "ok"
    end

    lambda { 
      BW::App.notification_center.post SampleNotification, Time.now, {:status => "ok"}
    }.should.change { notified }
  end

  it "remove observer" do
    lambda { 
      @observer = BW::App.notification_center.observe(SampleNotification) {}
      BW::App.notification_center.unobserve(@observer)
    }.should.not.change { BW::App.notification_center.observers.size }
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
bubble-wrap-1.4.0 spec/motion/core/ns_notification_center_spec.rb
bubble-wrap-1.3.0 spec/motion/core/ns_notification_center_spec.rb
bubble-wrap-1.3.0.osx spec/motion/core/ns_notification_center_spec.rb
bubble-wrap-1.2.0 spec/motion/core/ns_notification_center_spec.rb
bubble-wrap-1.2.0.pre spec/motion/core/ns_notification_center_spec.rb
bubble-wrap-1.1.5 spec/motion/core/ns_notification_center_spec.rb
bubble-wrap-1.1.4 spec/motion/core/ns_notification_center_spec.rb
bubble-wrap-1.1.3 spec/motion/core/ns_notification_center_spec.rb
bubble-wrap-1.1.2 spec/motion/core/ns_notification_center_spec.rb
bubble-wrap-1.1.1 spec/motion/core/ns_notification_center_spec.rb
bubble-wrap-1.1.0 spec/motion/core/ns_notification_center_spec.rb
bubble-wrap-1.0.0 spec/motion/core/ns_notification_center_spec.rb
bubble-wrap-1.0.0.pre.2 spec/motion/core/ns_notification_center_spec.rb
bubble-wrap-1.0.0.pre spec/core/ns_notification_center_spec.rb
bubble-wrap-0.4.0 spec/core/ns_notification_center_spec.rb
bubble-wrap-0.3.1 spec/ns_notification_center_spec.rb
bubble-wrap-0.3.0 spec/ns_notification_center_spec.rb