Commit e91f449d895102f8bc23553c9ec613bbec28dd1a

Specified posts/index.html.erb should have a containing div for the posts, should have a diff for each individual post, and should have the contents of the each post inside.

Commit diff

app/views/shared/_post.html.erb

 
1<div id="<%= post.id %>" class="post">
1<div id="post-<%= post.id %>" class="post">
22 <p class="body"><%= h( post.body ) %></p>
33 <p class="created"><%= relative_date( post.created_at ) %></p>
44</div>
toggle raw diff

log/merb_test.log

 
6464 ~ Post Load (0.000383) SELECT * FROM `posts` ORDER BY created_at DESC
6565 ~ {:action_time=>0.045942, :before_filters_time=>1.4e-05, :after_filters_time=>1.1e-05}
6666 ~ Post Columns (0.002168) SHOW FIELDS FROM `posts`
67 ~ Loaded TEST Environment...
68 ~ loading gem 'merb_activerecord' from ...
69 ~ loading gem 'merb_helpers' from ...
70 ~ loading gem 'activerecord' from ...
71 ~ Connecting to database...
72 ~ Compiling routes...
73 ~ Using 'share-nothing' cookie sessions (4kb limit per client)
74 ~ SQL (0.000232) SET NAMES 'utf8'
75 ~ SQL (0.000094) SET SQL_AUTO_IS_NULL=0
76 ~ Post Load (0.000406) SELECT * FROM `posts` ORDER BY created_at DESC
77 ~ {:action_time=>0.051055, :before_filters_time=>1.3e-05, :after_filters_time=>1.0e-05}
78 ~ Post Columns (0.002197) SHOW FIELDS FROM `posts`
79 ~ SQL (0.000147) BEGIN
80 ~ Post Create (0.000263) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:52:06', 'Merb Rawks', '2008-04-16 01:52:06')
81 ~ SQL (0.000455) COMMIT
82 ~ SQL (0.000078) BEGIN
83 ~ Post Create (0.000169) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:52:06', 'Like the Hawks', '2008-04-16 01:52:06')
84 ~ SQL (0.000560) COMMIT
85 ~ Post Load (0.000358) SELECT * FROM `posts` 
86 ~ SQL (0.000090) BEGIN
87 ~ Post Destroy (0.001051)  DELETE FROM `posts`
88 WHERE `id` = 1
89
90 ~ SQL (0.000498) COMMIT
91 ~ SQL (0.000132) BEGIN
92 ~ Post Destroy (0.000149)  DELETE FROM `posts`
93 WHERE `id` = 2
94
95 ~ SQL (0.000416) COMMIT
96 ~ SQL (0.000133) BEGIN
97 ~ Post Create (0.000210) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:52:06', 'Merb Rawks', '2008-04-16 01:52:06')
98 ~ SQL (0.000479) COMMIT
99 ~ SQL (0.000084) BEGIN
100 ~ Post Create (0.000165) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:52:06', 'Like the Hawks', '2008-04-16 01:52:06')
101 ~ SQL (0.000414) COMMIT
102 ~ Post Load (0.000278) SELECT * FROM `posts` 
103 ~ SQL (0.000076) BEGIN
104 ~ Post Destroy (0.000194)  DELETE FROM `posts`
105 WHERE `id` = 3
106
107 ~ SQL (0.000507) COMMIT
108 ~ SQL (0.000126) BEGIN
109 ~ Post Destroy (0.000141)  DELETE FROM `posts`
110 WHERE `id` = 4
111
112 ~ SQL (0.000451) COMMIT
113 ~ SQL (0.000338) BEGIN
114 ~ Post Create (0.000336) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:52:06', 'Merb Rawks', '2008-04-16 01:52:06')
115 ~ SQL (0.000546) COMMIT
116 ~ SQL (0.000132) BEGIN
117 ~ Post Create (0.000260) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:52:06', 'Like the Hawks', '2008-04-16 01:52:06')
118 ~ SQL (0.000519) COMMIT
119 ~ Post Load (0.000274) SELECT * FROM `posts` 
120 ~ SQL (0.000074) BEGIN
121 ~ Post Destroy (0.000218)  DELETE FROM `posts`
122 WHERE `id` = 5
123
124 ~ SQL (0.000491) COMMIT
125 ~ SQL (0.000128) BEGIN
126 ~ Post Destroy (0.000145)  DELETE FROM `posts`
127 WHERE `id` = 6
128
129 ~ SQL (0.000450) COMMIT
130 ~ Loaded TEST Environment...
131 ~ loading gem 'merb_activerecord' from ...
132 ~ loading gem 'merb_helpers' from ...
133 ~ loading gem 'activerecord' from ...
134 ~ Connecting to database...
135 ~ Compiling routes...
136 ~ Using 'share-nothing' cookie sessions (4kb limit per client)
137 ~ SQL (0.000238) SET NAMES 'utf8'
138 ~ SQL (0.000093) SET SQL_AUTO_IS_NULL=0
139 ~ Post Columns (0.001964) SHOW FIELDS FROM `posts`
140 ~ SQL (0.000122) BEGIN
141 ~ Post Create (0.000252) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:52:29', 'Merb Rawks', '2008-04-16 01:52:29')
142 ~ SQL (0.000421) COMMIT
143 ~ SQL (0.000095) BEGIN
144 ~ Post Create (0.000173) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:52:29', 'Like the Hawks', '2008-04-16 01:52:29')
145 ~ SQL (0.000384) COMMIT
146 ~ Post Load (0.000573) SELECT * FROM `posts` 
147 ~ SQL (0.000086) BEGIN
148 ~ Post Destroy (0.000207)  DELETE FROM `posts`
149 WHERE `id` = 7
150
151 ~ SQL (0.000416) COMMIT
152 ~ SQL (0.000125) BEGIN
153 ~ Post Destroy (0.000145)  DELETE FROM `posts`
154 WHERE `id` = 8
155
156 ~ SQL (0.000488) COMMIT
157 ~ SQL (0.000106) BEGIN
158 ~ Post Create (0.000232) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:52:29', 'Merb Rawks', '2008-04-16 01:52:29')
159 ~ SQL (0.000482) COMMIT
160 ~ SQL (0.000074) BEGIN
161 ~ Post Create (0.000185) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:52:29', 'Like the Hawks', '2008-04-16 01:52:29')
162 ~ SQL (0.000383) COMMIT
163 ~ Post Load (0.000401) SELECT * FROM `posts` 
164 ~ SQL (0.000085) BEGIN
165 ~ Post Destroy (0.000207)  DELETE FROM `posts`
166 WHERE `id` = 9
167
168 ~ SQL (0.000392) COMMIT
169 ~ SQL (0.000083) BEGIN
170 ~ Post Destroy (0.000175)  DELETE FROM `posts`
171 WHERE `id` = 10
172
173 ~ SQL (0.000367) COMMIT
174 ~ SQL (0.000146) BEGIN
175 ~ Post Create (0.000297) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:52:29', 'Merb Rawks', '2008-04-16 01:52:29')
176 ~ SQL (0.000462) COMMIT
177 ~ SQL (0.000081) BEGIN
178 ~ Post Create (0.000172) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:52:29', 'Like the Hawks', '2008-04-16 01:52:29')
179 ~ SQL (0.000373) COMMIT
180 ~ Post Load (0.000260) SELECT * FROM `posts` 
181 ~ SQL (0.000073) BEGIN
182 ~ Post Destroy (0.000188)  DELETE FROM `posts`
183 WHERE `id` = 11
184
185 ~ SQL (0.000411) COMMIT
186 ~ SQL (0.000138) BEGIN
187 ~ Post Destroy (0.000155)  DELETE FROM `posts`
188 WHERE `id` = 12
189
190 ~ SQL (0.000366) COMMIT
191 ~ Loaded TEST Environment...
192 ~ loading gem 'merb_activerecord' from ...
193 ~ loading gem 'merb_helpers' from ...
194 ~ loading gem 'activerecord' from ...
195 ~ Connecting to database...
196 ~ Compiling routes...
197 ~ Using 'share-nothing' cookie sessions (4kb limit per client)
198 ~ SQL (0.000215) SET NAMES 'utf8'
199 ~ SQL (0.000093) SET SQL_AUTO_IS_NULL=0
200 ~ Post Columns (0.001942) SHOW FIELDS FROM `posts`
201 ~ SQL (0.000112) BEGIN
202 ~ Post Create (0.000251) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:53:04', 'Merb Rawks', '2008-04-16 01:53:04')
203 ~ SQL (0.000449) COMMIT
204 ~ SQL (0.000086) BEGIN
205 ~ Post Create (0.000179) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:53:04', 'Like the Hawks', '2008-04-16 01:53:04')
206 ~ SQL (0.000423) COMMIT
207 ~ Post Load (0.000457) SELECT * FROM `posts` 
208 ~ SQL (0.000110) BEGIN
209 ~ Post Destroy (0.000241)  DELETE FROM `posts`
210 WHERE `id` = 13
211
212 ~ SQL (0.000500) COMMIT
213 ~ SQL (0.000109) BEGIN
214 ~ Post Destroy (0.000248)  DELETE FROM `posts`
215 WHERE `id` = 14
216
217 ~ SQL (0.000412) COMMIT
218 ~ SQL (0.000114) BEGIN
219 ~ Post Create (0.000216) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:53:04', 'Merb Rawks', '2008-04-16 01:53:04')
220 ~ SQL (0.000408) COMMIT
221 ~ SQL (0.000100) BEGIN
222 ~ Post Create (0.000187) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:53:04', 'Like the Hawks', '2008-04-16 01:53:04')
223 ~ SQL (0.000386) COMMIT
224 ~ Post Load (0.000310) SELECT * FROM `posts` 
225 ~ SQL (0.000077) BEGIN
226 ~ Post Destroy (0.000198)  DELETE FROM `posts`
227 WHERE `id` = 15
228
229 ~ SQL (0.000496) COMMIT
230 ~ SQL (0.000130) BEGIN
231 ~ Post Destroy (0.000150)  DELETE FROM `posts`
232 WHERE `id` = 16
233
234 ~ SQL (0.000419) COMMIT
235 ~ SQL (0.000108) BEGIN
236 ~ Post Create (0.000215) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:53:04', 'Merb Rawks', '2008-04-16 01:53:04')
237 ~ SQL (0.000462) COMMIT
238 ~ SQL (0.000076) BEGIN
239 ~ Post Create (0.000157) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:53:04', 'Like the Hawks', '2008-04-16 01:53:04')
240 ~ SQL (0.000447) COMMIT
241 ~ Post Load (0.000244) SELECT * FROM `posts` 
242 ~ SQL (0.000081) BEGIN
243 ~ Post Destroy (0.000189)  DELETE FROM `posts`
244 WHERE `id` = 17
245
246 ~ SQL (0.000479) COMMIT
247 ~ SQL (0.000124) BEGIN
248 ~ Post Destroy (0.000174)  DELETE FROM `posts`
249 WHERE `id` = 18
250
251 ~ SQL (0.000444) COMMIT
252 ~ Loaded TEST Environment...
253 ~ loading gem 'merb_activerecord' from ...
254 ~ loading gem 'merb_helpers' from ...
255 ~ loading gem 'activerecord' from ...
256 ~ Connecting to database...
257 ~ Compiling routes...
258 ~ Using 'share-nothing' cookie sessions (4kb limit per client)
259 ~ SQL (0.000223) SET NAMES 'utf8'
260 ~ SQL (0.000122) SET SQL_AUTO_IS_NULL=0
261 ~ Post Load (0.000366) SELECT * FROM `posts` ORDER BY created_at DESC
262 ~ {:action_time=>0.049436, :before_filters_time=>1.3e-05, :after_filters_time=>1.0e-05}
263 ~ Post Columns (0.002140) SHOW FIELDS FROM `posts`
264 ~ SQL (0.000141) BEGIN
265 ~ Post Create (0.000244) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:53:13', 'Merb Rawks', '2008-04-16 01:53:13')
266 ~ SQL (0.000428) COMMIT
267 ~ SQL (0.000096) BEGIN
268 ~ Post Create (0.000208) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:53:13', 'Like the Hawks', '2008-04-16 01:53:13')
269 ~ SQL (0.000584) COMMIT
270 ~ Post Load (0.000373) SELECT * FROM `posts` 
271 ~ SQL (0.000115) BEGIN
272 ~ Post Destroy (0.000279)  DELETE FROM `posts`
273 WHERE `id` = 19
274
275 ~ SQL (0.000709) COMMIT
276 ~ SQL (0.000099) BEGIN
277 ~ Post Destroy (0.000241)  DELETE FROM `posts`
278 WHERE `id` = 20
279
280 ~ SQL (0.000354) COMMIT
281 ~ SQL (0.000120) BEGIN
282 ~ Post Create (0.000264) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:53:13', 'Merb Rawks', '2008-04-16 01:53:13')
283 ~ SQL (0.000418) COMMIT
284 ~ SQL (0.000104) BEGIN
285 ~ Post Create (0.000229) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:53:13', 'Like the Hawks', '2008-04-16 01:53:13')
286 ~ SQL (0.000483) COMMIT
287 ~ Post Load (0.000416) SELECT * FROM `posts` 
288 ~ SQL (0.000100) BEGIN
289 ~ Post Destroy (0.000241)  DELETE FROM `posts`
290 WHERE `id` = 21
291
292 ~ SQL (0.008838) COMMIT
293 ~ SQL (0.000229) BEGIN
294 ~ Post Destroy (0.000283)  DELETE FROM `posts`
295 WHERE `id` = 22
296
297 ~ SQL (0.000397) COMMIT
298 ~ SQL (0.000107) BEGIN
299 ~ Post Create (0.000228) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:53:13', 'Merb Rawks', '2008-04-16 01:53:13')
300 ~ SQL (0.000413) COMMIT
301 ~ SQL (0.000083) BEGIN
302 ~ Post Create (0.005116) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:53:13', 'Like the Hawks', '2008-04-16 01:53:13')
303 ~ SQL (0.000478) COMMIT
304 ~ Post Load (0.000394) SELECT * FROM `posts` 
305 ~ SQL (0.000090) BEGIN
306 ~ Post Destroy (0.001041)  DELETE FROM `posts`
307 WHERE `id` = 23
308
309 ~ SQL (0.000390) COMMIT
310 ~ SQL (0.000081) BEGIN
311 ~ Post Destroy (0.000177)  DELETE FROM `posts`
312 WHERE `id` = 24
313
314 ~ SQL (0.007458) COMMIT
315 ~ Loaded TEST Environment...
316 ~ loading gem 'merb_activerecord' from ...
317 ~ loading gem 'merb_helpers' from ...
318 ~ loading gem 'activerecord' from ...
319 ~ Connecting to database...
320 ~ Compiling routes...
321 ~ Using 'share-nothing' cookie sessions (4kb limit per client)
322 ~ SQL (0.000229) SET NAMES 'utf8'
323 ~ SQL (0.000094) SET SQL_AUTO_IS_NULL=0
324 ~ Post Load (0.000379) SELECT * FROM `posts` ORDER BY created_at DESC
325 ~ {:action_time=>0.045661, :before_filters_time=>1.3e-05, :after_filters_time=>9.0e-06}
326 ~ Post Columns (0.002140) SHOW FIELDS FROM `posts`
327 ~ SQL (0.000156) BEGIN
328 ~ Post Create (0.000251) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:55:22', 'Merb Rawks', '2008-04-16 01:55:22')
329 ~ SQL (0.000379) COMMIT
330 ~ SQL (0.000082) BEGIN
331 ~ Post Create (0.000212) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:55:22', 'Like the Hawks', '2008-04-16 01:55:22')
332 ~ SQL (0.000832) COMMIT
333 ~ Post Load (0.000282) SELECT * FROM `posts` 
334 ~ SQL (0.000076) BEGIN
335 ~ Post Destroy (0.000200)  DELETE FROM `posts`
336 WHERE `id` = 25
337
338 ~ SQL (0.000494) COMMIT
339 ~ SQL (0.000128) BEGIN
340 ~ Post Destroy (0.000146)  DELETE FROM `posts`
341 WHERE `id` = 26
342
343 ~ SQL (0.000441) COMMIT
344 ~ SQL (0.000102) BEGIN
345 ~ Post Create (0.000204) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:55:22', 'Merb Rawks', '2008-04-16 01:55:22')
346 ~ SQL (0.000447) COMMIT
347 ~ SQL (0.000092) BEGIN
348 ~ Post Create (0.000198) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:55:22', 'Like the Hawks', '2008-04-16 01:55:22')
349 ~ SQL (0.000412) COMMIT
350 ~ Post Load (0.000283) SELECT * FROM `posts` 
351 ~ SQL (0.000076) BEGIN
352 ~ Post Destroy (0.000244)  DELETE FROM `posts`
353 WHERE `id` = 27
354
355 ~ SQL (0.000423) COMMIT
356 ~ SQL (0.000125) BEGIN
357 ~ Post Destroy (0.000140)  DELETE FROM `posts`
358 WHERE `id` = 28
359
360 ~ SQL (0.000483) COMMIT
361 ~ SQL (0.001194) BEGIN
362 ~ Post Create (0.000376) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:55:22', 'Merb Rawks', '2008-04-16 01:55:22')
363 ~ SQL (0.000593) COMMIT
364 ~ SQL (0.000096) BEGIN
365 ~ Post Create (0.000205) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-16 01:55:22', 'Like the Hawks', '2008-04-16 01:55:22')
366 ~ SQL (0.000451) COMMIT
367 ~ Post Load (0.000281) SELECT * FROM `posts` 
368 ~ SQL (0.000075) BEGIN
369 ~ Post Destroy (0.013491)  DELETE FROM `posts`
370 WHERE `id` = 29
371
372 ~ SQL (0.000489) COMMIT
373 ~ SQL (0.000080) BEGIN
374 ~ Post Destroy (0.000206)  DELETE FROM `posts`
375 WHERE `id` = 30
376
377 ~ SQL (0.000701) COMMIT
toggle raw diff

spec/views/posts/index_spec.rb

 
1require File.join(File.dirname(__FILE__), "..", "..", "spec_helper.rb")
2
3describe "posts/index" do
4
5 before( :each ) do
6 @controller = Posts.new( fake_request )
7 @posts = [Post.create( :body => "Merb Rawks", :created_at => Time.now ), Post.create( :body => "Like the Hawks", :created_at => Time.now )]
8 @controller.instance_variable_set( :@posts, @posts )
9 @body = @controller.render( :index )
10 end
11
12 it "should have a containing div for the posts" do
13 @body.should have_selector( "div#posts.container" )
14 end
15
16 it "should have a div for each individual post" do
17 @posts.each do |post|
18 @body.should have_selector( "div#posts.container div#post-#{ post.id }.post" )
19 end
20 end
21
22 it "should have the contents of each post inside a div with an id and class" do
23 @posts.each do |post|
24 @body.should match_tag( :div, :id => "post-#{ post.id }", :class => "post", :content => post.body )
25 end
26 end
27
28 after( :each ) do
29 Post.destroy_all
30 end
31
32end
toggle raw diff