Sha256: 643e4095436127e2691cc6b9c9b8d4b33ae020e2b70b89f96a8424d0a295adfe
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
class DependantKeysTest attr_reader :a, :b, :c keys_affecting :a => [:b, :c] def initialize @a = "a" @b = "b" @c = "c" end def a=(a) @a = a end def a "#{@a}_#{b}_#{c}" end def b=(b) @b = b end def c=(c) @c = c end end describe "KeyValueObserving#keys_affecting" do it "should notify observer when an affecting key is changed" do # puts "===================================================================" obj = DependantKeysTest.new capture_a = nil notification_count = 0 notifications = [] obj.observe :a do |changes| notifications << :a capture_a = obj.a notification_count = notification_count + 1 end obj.observe :b do |changes| notifications << :b end obj.observe :c do |changes| notifications << :c end obj.a = "adam" capture_a.should == "adam_b_c" notification_count.should == 1 notifications.should == [:a] notifications = [] obj.b = "tom" capture_a.should == "adam_tom_c" notification_count.should == 2 notifications.should == [:b, :a] notifications = [] obj.c = "ben" capture_a.should == "adam_tom_ben" notification_count.should == 3 notifications.should == [:c, :a] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
opal-0.1.0 | opals/foundation/spec/system/observable/dependant_keys_spec.rb |