Sha256: fd44dd687a7bef0788947e26cfae351edce1fe078d15ab1ec12ff9ae6034e4d9

Contents?: true

Size: 1.32 KB

Versions: 46

Compression:

Stored size: 1.32 KB

Contents

class NotificationsTester
  attr :notification
  attr :object

  def reset!
    @notified = nil
    @notification = nil
    @object = nil
  end

  def notified?
    @notified
  end

  def BAM(notification)
    @notified = true
    @notification = notification
    @object = notification.object
  end
end

describe "Notifications" do

  before do
    @notification = 'NotificationName'
    @object = 'specific object'
    @notification_tester = NotificationsTester.new
    @notification_tester_object = NotificationsTester.new

    @notification.add_observer(@notification_tester, :'BAM:')
    @notification.add_observer(@notification_tester_object, :'BAM:', @object)
  end

  it "should post and receive notification" do
    @notification_tester.reset!
    @notification_tester_object.reset!

    @notification.post_notification
    @notification_tester.notified?.should == true
    @notification_tester.notification.should != nil
    @notification_tester.object.should == nil

    @notification.post_notification(@object)
    @notification_tester_object.notified?.should == true
    @notification_tester_object.notification.should != nil
    @notification_tester_object.object.should == @object
  end

  after do
    @notification.remove_observer(@notification_tester)
    @notification.remove_observer(@notification_tester_object, @object)
  end

end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
sugarcube-0.19.0 spec/notification_spec.rb
sugarcube-0.18.21 spec/notification_spec.rb
sugarcube-0.18.20 spec/notification_spec.rb
sugarcube-0.18.19 spec/notification_spec.rb
sugarcube-0.18.18 spec/notification_spec.rb
sugarcube-0.18.17 spec/notification_spec.rb
sugarcube-0.18.16 spec/notification_spec.rb
sugarcube-0.18.12 spec/notification_spec.rb
sugarcube-0.18.11 spec/notification_spec.rb
sugarcube-0.18.10 spec/notification_spec.rb
sugarcube-0.18.9 spec/notification_spec.rb
sugarcube-0.18.8 spec/notification_spec.rb
sugarcube-0.18.7 spec/notification_spec.rb
sugarcube-0.18.6 spec/notification_spec.rb
sugarcube-0.18.5 spec/notification_spec.rb
sugarcube-0.18.4 spec/notification_spec.rb
sugarcube-0.18.3 spec/notification_spec.rb
sugarcube-0.18.2 spec/notification_spec.rb
sugarcube-0.18.1 spec/notification_spec.rb
sugarcube-0.18.0 spec/notification_spec.rb