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.20.18 spec/notification_spec.rb
sugarcube-0.20.17 spec/notification_spec.rb
sugarcube-0.20.16 spec/notification_spec.rb
sugarcube-0.20.15 spec/notification_spec.rb
sugarcube-0.20.13 spec/notification_spec.rb
sugarcube-0.20.12 spec/notification_spec.rb
sugarcube-0.20.11 spec/notification_spec.rb
sugarcube-0.20.10 spec/notification_spec.rb
sugarcube-0.20.9 spec/notification_spec.rb
sugarcube-0.20.8 spec/notification_spec.rb
sugarcube-0.20.7 spec/notification_spec.rb
sugarcube-0.20.6 spec/notification_spec.rb
sugarcube-0.20.5 spec/notification_spec.rb
sugarcube-0.20.4 spec/notification_spec.rb
sugarcube-0.20.3 spec/notification_spec.rb
sugarcube-0.20.1 spec/notification_spec.rb
sugarcube-0.20.0 spec/notification_spec.rb
sugarcube-0.19.5 spec/notification_spec.rb
sugarcube-0.19.4 spec/notification_spec.rb
sugarcube-0.19.2 spec/notification_spec.rb