association_observers 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,44 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require './spec/spec_helper'
3
+ require 'examples/readme_example'
4
+
5
+
6
+
7
+ describe "readme example" do
8
+ let(:mom){ Mom.create(:kid => Kid.create) }
9
+ let(:kid){ mom.kid }
10
+ let(:default_slices) {8}
11
+ describe "when momma bakes a cake" do
12
+ let(:cake) { mom.cakes.create(:slices => default_slices) }
13
+ it "should have a slice eaten by the kid" do
14
+ cake
15
+ mom.cakes.last.reload.slices.should == Cake.default_slices - 1
16
+ mom.kid.reload.slices.should == 1
17
+ end
18
+ it "should not tell the kid he's fat" do
19
+ kid.should_not_receive(:cry!)
20
+ kid.should_not_receive(:throw_slices_away!)
21
+ end
22
+ describe "and the cake is fully eaten by the kid" do
23
+ let(:default_slices) {1}
24
+ it "should bust kids ass" do
25
+ LOGGER.should_receive(:info).with("Slam!!")
26
+ cake
27
+ end
28
+ end
29
+ describe "and the kid has plenty of slices" do
30
+ before(:each) do
31
+ kid.update_column(:slices, 20)
32
+ end
33
+ it "should tell kid he's fat" do
34
+ LOGGER.should_receive(:info).with("Hey Fatty, BEEFCAKE!!!!!")
35
+ LOGGER.should_receive(:info).with(":'(")
36
+ cake
37
+ kid.reload.slices.should == 0
38
+ end
39
+ end
40
+ end
41
+
42
+
43
+
44
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'rubygems'
3
+ require 'active_record'
4
+ require './lib/association_observers'
5
+
6
+
7
+ ActiveRecord::Base.configurations = YAML.load_file(File.join(File.expand_path('../..', __FILE__), 'database.yml'))
8
+ ActiveRecord::Base.establish_connection("activerecord")
9
+
10
+
11
+ require 'rspec'
12
+ require 'database_cleaner'
13
+
14
+ RSpec.configure do |config|
15
+
16
+ config.before(:each) do
17
+ DatabaseCleaner.strategy = :transaction
18
+ DatabaseCleaner.start
19
+ end
20
+ config.after(:each) do
21
+ DatabaseCleaner.clean
22
+ end
23
+
24
+ config.mock_with :rspec
25
+ end
26
+
metadata ADDED
@@ -0,0 +1,223 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: association_observers
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.3
6
+ platform: ruby
7
+ authors:
8
+ - Tiago Cardoso
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ version_requirements: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: 0.9.2.2
21
+ none: false
22
+ requirement: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.9.2.2
27
+ none: false
28
+ prerelease: false
29
+ type: :development
30
+ - !ruby/object:Gem::Dependency
31
+ name: rack-test
32
+ version_requirements: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - '='
35
+ - !ruby/object:Gem::Version
36
+ version: 0.6.2
37
+ none: false
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - '='
41
+ - !ruby/object:Gem::Version
42
+ version: 0.6.2
43
+ none: false
44
+ prerelease: false
45
+ type: :development
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ~>
51
+ - !ruby/object:Gem::Version
52
+ version: 2.11.0
53
+ none: false
54
+ requirement: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ version: 2.11.0
59
+ none: false
60
+ prerelease: false
61
+ type: :development
62
+ - !ruby/object:Gem::Dependency
63
+ name: database_cleaner
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 0.8.0
69
+ none: false
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '='
73
+ - !ruby/object:Gem::Version
74
+ version: 0.8.0
75
+ none: false
76
+ prerelease: false
77
+ type: :development
78
+ - !ruby/object:Gem::Dependency
79
+ name: colorize
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - '='
83
+ - !ruby/object:Gem::Version
84
+ version: 0.5.8
85
+ none: false
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '='
89
+ - !ruby/object:Gem::Version
90
+ version: 0.5.8
91
+ none: false
92
+ prerelease: false
93
+ type: :development
94
+ - !ruby/object:Gem::Dependency
95
+ name: pry
96
+ version_requirements: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
100
+ version: !binary |-
101
+ MA==
102
+ none: false
103
+ requirement: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: !binary |-
108
+ MA==
109
+ none: false
110
+ prerelease: false
111
+ type: :development
112
+ - !ruby/object:Gem::Dependency
113
+ name: pry-doc
114
+ version_requirements: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: !binary |-
119
+ MA==
120
+ none: false
121
+ requirement: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: !binary |-
126
+ MA==
127
+ none: false
128
+ prerelease: false
129
+ type: :development
130
+ - !ruby/object:Gem::Dependency
131
+ name: awesome_print
132
+ version_requirements: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ! '>='
135
+ - !ruby/object:Gem::Version
136
+ version: !binary |-
137
+ MA==
138
+ none: false
139
+ requirement: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ! '>='
142
+ - !ruby/object:Gem::Version
143
+ version: !binary |-
144
+ MA==
145
+ none: false
146
+ prerelease: false
147
+ type: :development
148
+ description: ! "This is an alternative implementation of the observer pattern. As\
149
+ \ you may know, Ruby (and Rails/ActiveRecord) already have an\n implementation\
150
+ \ of it. This implementation is a variation of the pattern, so it is not supposed\
151
+ \ to supersede the existing\n implementations, but \"complete\" them for the specific\
152
+ \ use-cases addressed."
153
+ email:
154
+ - tiago@restorm.com
155
+ executables: []
156
+ extensions: []
157
+ extra_rdoc_files: []
158
+ files:
159
+ - .gitignore
160
+ - .pryrc
161
+ - .rspec
162
+ - .travis.yml
163
+ - Gemfile
164
+ - LICENSE.txt
165
+ - README.md
166
+ - Rakefile
167
+ - association_observers.gemspec
168
+ - database.yml
169
+ - lib/association_observers.rb
170
+ - lib/association_observers/activerecord.rb
171
+ - lib/association_observers/notifiers/base.rb
172
+ - lib/association_observers/notifiers/propagation_notifier.rb
173
+ - lib/association_observers/railtie.rb
174
+ - lib/association_observers/ruby18.rb
175
+ - lib/association_observers/version.rb
176
+ - lib/examples/notifiers/update_timestamp_notifier.rb
177
+ - lib/examples/readme_example.rb
178
+ - spec/activerecord/association_observers_spec.rb
179
+ - spec/examples/readme_example_spec.rb
180
+ - spec/spec_helper.rb
181
+ homepage: https://github.com/TiagoCardoso1983/association_observers
182
+ licenses: []
183
+ post_install_message:
184
+ rdoc_options: []
185
+ require_paths:
186
+ - lib
187
+ required_ruby_version: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ! '>='
190
+ - !ruby/object:Gem::Version
191
+ segments:
192
+ - 0
193
+ hash: 2
194
+ version: !binary |-
195
+ MA==
196
+ none: false
197
+ required_rubygems_version: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ! '>='
200
+ - !ruby/object:Gem::Version
201
+ segments:
202
+ - 0
203
+ hash: 2
204
+ version: !binary |-
205
+ MA==
206
+ none: false
207
+ requirements: []
208
+ rubyforge_project:
209
+ rubygems_version: 1.8.24
210
+ signing_key:
211
+ specification_version: 3
212
+ summary: ! 'The Observer Pattern clearly defines two roles: the observer and the observed.
213
+ The observer registers itself by the observed. The observed decides when (for which
214
+ "actions") to notify the observer. The observer knows what to do when notified. What''s
215
+ the limitation? The observed has to know when and whom to notify. The observer has
216
+ to know what to do. For this logic to be implemented for two other separate entities,
217
+ behaviour has to be copied from one place to the other. So, why not delegate this
218
+ information (to whom, when, behaviour) to a third role, the notifier?'
219
+ test_files:
220
+ - spec/activerecord/association_observers_spec.rb
221
+ - spec/examples/readme_example_spec.rb
222
+ - spec/spec_helper.rb
223
+ has_rdoc: