alakazam 0.3 → 0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88403d21dadf02d5883da0004dc3431b83869f58
4
- data.tar.gz: 60521c83237c0be9528f0431c4851b56e68fffb1
3
+ metadata.gz: f7e546b8e9b56aa661e5dc502703e3ff6d8a516a
4
+ data.tar.gz: cba0f10b5cd8f9348bbac287a1b0780f4bd22fed
5
5
  SHA512:
6
- metadata.gz: 2aabcfe69b837cfef0ab73fb5b7193691601792ff8b3f4009d8bb1451f4305431947d39662fa2ca0bc0f179c2c70a0952873a2ac9346398d944434823d295228
7
- data.tar.gz: fa3fc31cb095f077706fe758301edd9ab713cca8281d543e8a24a587d39bc859bbb2033488528c3d09d17c7c4f56cfba700b019e7314d8ba14c21163bdaa3d50
6
+ metadata.gz: 895345f8dc171978d18f048807f5aa0e91c85cb64db60217bf161b4d8cbc5c401f7f01a4bdb5484fc37c5323ba36e4bd9b6705d33550ee14057b4e552150d144
7
+ data.tar.gz: d93f479e6621557200d303cd74186705f721b57a392467bc1688d4d9c014f1537c7371c9b9afb61b3d2696f6423ab997be33e77d362ed5d3267697a2ab6ecc4a
@@ -9,5 +9,5 @@
9
9
  #++
10
10
 
11
11
  module Alakazam
12
- VERSION = '0.3'
12
+ VERSION = '0.4'
13
13
  end
@@ -31,35 +31,40 @@ class Shiftry
31
31
  end
32
32
 
33
33
  class Logger
34
+ def initialize
35
+ @i = 0
36
+ end
37
+
34
38
  def update(*things)
35
- $i += 1
39
+ @i += 1
40
+ end
41
+
42
+ def counter
43
+ @i
36
44
  end
37
45
 
38
46
  def self.on_fire(*things)
39
- $i += 1
47
+ @@i = 0 if not defined? @@i
48
+ @@i += 1
49
+ end
50
+
51
+ def self.counter
52
+ @@i
40
53
  end
41
54
  end
42
55
 
43
56
  describe Alakazam do
44
57
  before do
45
- $i = 0
46
- end
47
-
48
- let(:counter) do
49
- counter = $i
58
+ @counter = 0
50
59
  end
51
60
 
52
61
  let(:logger) do
53
- logger = ->(*things) { $i += 1 }
54
- end
55
-
56
- let(:shiftry) do
57
- shiftry = Shiftry.new
62
+ ->(*things) {
63
+ @counter += 1
64
+ }
58
65
  end
59
66
 
60
- after do
61
- $i = 0
62
- end
67
+ let(:shiftry) { Shiftry.new }
63
68
 
64
69
  it 'invokes a Proc when notified by observed class' do
65
70
  shiftry.is_observed_by logger
@@ -70,7 +75,7 @@ describe Alakazam do
70
75
  shiftry.lel
71
76
  shiftry.lel
72
77
 
73
- counter.should be 2
78
+ @counter.should be 2
74
79
  end
75
80
 
76
81
  it 'invokes a Proc without explicit notify when notified by observed class' do
@@ -82,7 +87,7 @@ describe Alakazam do
82
87
  shiftry.lel
83
88
  shiftry.lel
84
89
 
85
- counter.should be 4
90
+ @counter.should be 4
86
91
  end
87
92
 
88
93
  it 'invokes a Proc when notified by a class method of the observed class' do
@@ -91,27 +96,30 @@ describe Alakazam do
91
96
  Shiftry.lul
92
97
  Shiftry.lul
93
98
 
94
- counter.should be 2
99
+ @counter.should be 2
95
100
  end
96
101
 
97
102
  it 'invokes the logger\'s custom and default method when notified by observed class' do
103
+ logger = Logger.new
104
+
98
105
  shiftry.is_observed_by Logger.new, methods: [ :on_fire, :non_existing_method ]
99
- shiftry.is_observed_by Logger.new
106
+ shiftry.is_observed_by logger
100
107
 
101
108
  shiftry.lol
102
109
 
103
- counter.should be 2
110
+ logger.counter.should be 1
111
+ Logger.counter.should be 1
104
112
  end
105
113
 
106
114
  it 'invokes the logger\'s default method when a variable changes in the observed class' do
107
- shiftry.is_observed_by Logger.new, attributes: { var: :lal, notify: 'fired' }
108
-
109
- shiftry.lal = 3
110
- shiftry.lal.should be 3
115
+ Logger.new.tap { |logger|
116
+ shiftry.is_observed_by logger, attributes: { var: :lal, notify: 'fired' }
111
117
 
112
- shiftry.lal = 4
113
- shiftry.lal.should be 4
118
+ shiftry.lal = 3
119
+ shiftry.lal.should be 3
114
120
 
115
- counter.should be 2
121
+ shiftry.lal = 4
122
+ shiftry.lal.should be 4
123
+ }.counter.should be 2
116
124
  end
117
125
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alakazam
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: '0.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Giovanni Capuano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-01 00:00:00.000000000 Z
11
+ date: 2014-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake