motion_bindable 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/motion_bindable/version.rb +1 -1
- data/lib/strategies/ui_text_field.rb +3 -3
- data/spec/strategy_spec.rb +6 -0
- data/spec/ui_text_field_strategy_spec.rb +11 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5c897c0eb305bd4f7b5ffd32cf03c647c02f225
|
4
|
+
data.tar.gz: cd0bf8cc88ac483a0296e0fc0399cf157dd77e32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be96fcb5c62954e620367ebf7318eaa3aa2ea5fc9367d375aa6a472ada78e5f2e3d4b7de5c7f753837f741acfa350a604fe177c60f6e9f53e8b8f6dc57ad44b1
|
7
|
+
data.tar.gz: 523280e1eb706f1b561e9e81f52512537a49e3e824487ef2ec896eeaf41f739f3bd6f3267fbf2266bf85b07ccc4a51df32ddf44e34961b4fac17ecaab09bbc7b
|
@@ -3,7 +3,7 @@ module MotionBindable::Strategies
|
|
3
3
|
class UITextField < ::MotionBindable::Strategy
|
4
4
|
|
5
5
|
def start_observing_bound
|
6
|
-
NSNotificationCenter.defaultCenter.addObserverForName(
|
6
|
+
@bound_observer = NSNotificationCenter.defaultCenter.addObserverForName(
|
7
7
|
UITextFieldTextDidChangeNotification,
|
8
8
|
object: bound,
|
9
9
|
queue: nil,
|
@@ -30,8 +30,8 @@ module MotionBindable::Strategies
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def unbind
|
33
|
-
|
34
|
-
|
33
|
+
NSNotificationCenter.defaultCenter.removeObserver(@bound_observer)
|
34
|
+
object.removeObserver(self, forKeyPath: @attr_name)
|
35
35
|
super
|
36
36
|
end
|
37
37
|
|
data/spec/strategy_spec.rb
CHANGED
@@ -74,6 +74,12 @@ describe 'MotionBindable::Strategy' do
|
|
74
74
|
it 'should respond' do
|
75
75
|
@strategy.respond_to?(:unbind).should.equal true
|
76
76
|
end
|
77
|
+
|
78
|
+
it 'should clear the watcher' do
|
79
|
+
wait(0.5) do
|
80
|
+
@strategy.instance_variable_get(:@watching).should.equal nil
|
81
|
+
end
|
82
|
+
end
|
77
83
|
end
|
78
84
|
|
79
85
|
end
|
@@ -73,6 +73,17 @@ describe 'MotionBindable::Strategies::UITextField' do
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
+
context 'unbind is called' do
|
77
|
+
before do
|
78
|
+
@object.unbind_all
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should no longer update when the text field changed' do
|
82
|
+
@text_field.text = 'ch-changed'
|
83
|
+
@object.attribute.should.not.equal 'ch-changed'
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
76
87
|
end
|
77
88
|
|
78
89
|
end
|