Sha256: 66426fd4d1b26234380dc7f1d3d383b022e603fed790f653a5a67fb069bef496

Contents?: true

Size: 1.11 KB

Versions: 9

Compression:

Stored size: 1.11 KB

Contents

require "more/spec_helper"

describe "Observable" do
  class AnObservable
    include RubyExt::Observable
  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: -> {|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: -> {|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

9 entries across 9 versions & 1 rubygems

Version Path
ruby_ext-0.5.9 spec/more/observable_spec.rb
ruby_ext-0.5.8 spec/more/observable_spec.rb
ruby_ext-0.5.7 spec/more/observable_spec.rb
ruby_ext-0.5.6 spec/more/observable_spec.rb
ruby_ext-0.5.5 spec/more/observable_spec.rb
ruby_ext-0.5.4 spec/more/observable_spec.rb
ruby_ext-0.5.3 spec/more/observable_spec.rb
ruby_ext-0.5.2 spec/more/observable_spec.rb
ruby_ext-0.5.1 spec/more/observable_spec.rb