Sha256: 85d5950d6848fc5717d070d7927a425e545babbb655be54dd61d358053c229e8

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

require "spec_helper"
require "ruby_ext/observable2"

describe "Observable" do
  class AnObservable
    include Observable2
  end
  
  it "Method without Parameters" do
    mock = mock("Observer")
    obs = AnObservable.new
    obs.add_observer mock
    mock.should_receive(:update).with(2)
    obs.notify_observers :update, 2      
  end
  
     # it "Method without Parameters" do
     #   mock = mock("Observer")
     #   obs = AnObservable.new
     #   obs.add_observer(mock, :method => :custom_update, :filter => lambda{|o| o == 2})
     #   mock.should_receive(:custom_update).with(2)
     #   obs.notify_observers 2
     #   obs.notify_observers 4
     # end
     # 
     # it "With Block" do
     #   mock = mock("Observer")
     #   mock.should_receive(:got)
     #   obs = AnObservable.new
     #   obs.add_observer{mock.got}
     #   obs.notify_observers
     # end
     # 
     # it "With Block and Filter" do
     #   mock = mock("Observer")
     #   obs = AnObservable.new
     #   obs.add_observer(:filter => lambda{|o| o == 2}){|o| mock.got o}
     #   mock.should_receive(:got).with(2)
     #   obs.notify_observers 2
     #   obs.notify_observers 4                  
     # end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby_ext-0.4.11 spec/observable2_spec.rb
ruby_ext-0.4.10 spec/observable2_spec.rb
ruby_ext-0.4.9 spec/observable2_spec.rb