after_do 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/after_do.rb +5 -3
- data/lib/after_do/version.rb +1 -1
- data/spec/after_do_spec.rb +15 -5
- 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: 1a27fee536c317e5ba1edbfe81e495dccad4f1fc
|
4
|
+
data.tar.gz: d0c51288921b665794ec7b89130d3b27584eef36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd71a09544a38876a753c5f24cc01fb5e607152167d061f4616504645b9867952ff4b719d8b1ae9f3f5ce428a9d80da74612f3c3d9b2e9d86aa275cd7edb8bec
|
7
|
+
data.tar.gz: f8a079648a8b52de280ccd31a8d7b117eac59e862614ea34beafd05a82e12406bcfa62de2ba393b92b65c6fe86c4062942a6c396914120b4a138d496996cc09d
|
data/lib/after_do.rb
CHANGED
@@ -42,7 +42,11 @@ module AfterDo
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def _after_do_basic_hash
|
45
|
-
{
|
45
|
+
{after: _after_do_methods_hash, before: _after_do_methods_hash}
|
46
|
+
end
|
47
|
+
|
48
|
+
def _after_do_methods_hash
|
49
|
+
Hash.new {|hash, key| hash[key] = []}
|
46
50
|
end
|
47
51
|
|
48
52
|
def _after_do_add_callback_to_method(type, method, block)
|
@@ -54,8 +58,6 @@ module AfterDo
|
|
54
58
|
|
55
59
|
def _after_do_make_after_do_version_of_method(method)
|
56
60
|
_after_do_raise_no_method_error(method) unless _after_do_defined?(method)
|
57
|
-
@_after_do_callbacks[:before][method] = []
|
58
|
-
@_after_do_callbacks[:after][method] = []
|
59
61
|
alias_name = _after_do_aliased_name method
|
60
62
|
_after_do_rename_old_method(method, alias_name)
|
61
63
|
_after_do_redefine_method_with_callback(method, alias_name)
|
data/lib/after_do/version.rb
CHANGED
data/spec/after_do_spec.rb
CHANGED
@@ -71,11 +71,21 @@ describe AfterDo do
|
|
71
71
|
dummy_instance.zero
|
72
72
|
end
|
73
73
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
74
|
+
describe 'removing callbacks' do
|
75
|
+
it 'can remove all callbacks' do
|
76
|
+
mockie.should_not_receive :call_method
|
77
|
+
@dummy_class.send callback_adder, :zero do mockie.call_method end
|
78
|
+
@dummy_class.remove_all_callbacks
|
79
|
+
dummy_instance.zero
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'does not crash the addition of new callbacks afterwards' do
|
83
|
+
mockie.should_receive :call_method
|
84
|
+
@dummy_class.send callback_adder, :zero do mockie.call_method end
|
85
|
+
@dummy_class.remove_all_callbacks
|
86
|
+
@dummy_class.send callback_adder, :zero do mockie.call_method end
|
87
|
+
dummy_instance.zero
|
88
|
+
end
|
79
89
|
end
|
80
90
|
|
81
91
|
describe 'errors' do
|