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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 53c375dcc4890f556937b57e4c425fe504bc5774
4
- data.tar.gz: 66f9df14bb68c11f643e36d267b80eb435c7ea6a
3
+ metadata.gz: 1a27fee536c317e5ba1edbfe81e495dccad4f1fc
4
+ data.tar.gz: d0c51288921b665794ec7b89130d3b27584eef36
5
5
  SHA512:
6
- metadata.gz: 9848d290fe04c511fe23f0ce298033626ee2ae75f4720c5118aaf9f553703fb1d2c095853d312ee2275bb77c11abc0be46a72ac8a2983bdc295d723064fa20e7
7
- data.tar.gz: 21ea282c3a6c143c1efd2491df07cd53e66b8967006143c0b63d68e9608b79c705f4ff8d7b7e9ca54e9a55ac77a28a802b1b48317c0360008c6ad1e5e95ef381
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
- {before: {}, after: {}}
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)
@@ -1,3 +1,3 @@
1
1
  module AfterDo
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -71,11 +71,21 @@ describe AfterDo do
71
71
  dummy_instance.zero
72
72
  end
73
73
 
74
- it 'can remove all callbacks' do
75
- mockie.should_not_receive :call_method
76
- @dummy_class.send callback_adder, :zero do mockie.call_method end
77
- @dummy_class.remove_all_callbacks
78
- dummy_instance.zero
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: after_do
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Pfeiffer