public
Description: Life On The Edge With Merb, DataMapper & RSpec
Homepage: http://blog.new-bamboo.co.uk
Clone URL: git://github.com/deimos1986/book_mdar.git
Re-wrote controller spec paragraphs to reflect code example
namelessjon (author)
Fri Jul 18 12:37:59 -0700 2008
commit  39f5fbaf4d32a2a063714402ae52ede7685bfa69
tree    b507344e004c0914382d8f0bb20b81df4921d933
parent  540e0c1d145fe10423295e49cc80a9fd1b045630
...
37
38
39
40
41
42
43
44
45
46
47
48
49
 
 
 
 
 
 
 
 
50
51
52
...
37
38
39
 
 
 
 
 
 
 
 
 
 
40
41
42
43
44
45
46
47
48
49
50
0
@@ -37,16 +37,14 @@ The first should_receive ensures that Post.get!(1) is called, we could mock out
0
 a Post instance to return here, but in this case we're only interested in it
0
 being called and not raising an exception.
0
 
0
-Next we use the get method to make a request to the controller, the :yields
0
-option allows us to set what the get request returns. Here we want to grab the
0
-controller and then stub out the render method before the request is made.
0
-Anything inside you get method's block will be executed before the request is
0
-dispatched.
0
-
0
-After the request has been dispatched, several methods are available to return
0
-the results from the request: body, status, params, cookies, headers, session,
0
-response and route. Note that these all just call the same method on controller
0
-(so status is the same as controller.status).
0
+Next we use the get method to make a request to the controller. The get method
0
+yields the controller, allowing us to stub out the render method, as we're not
0
+interested in how that behaves. Anything inside the get method's block will be
0
+executed before the request is dispatched.
0
+
0
+After the request has been dispatched, it returns the controller. Several
0
+methods are available to examine the results from the request: body, status,
0
+params, cookies, headers, session, response and route.
0
 
0
 This test was fairly simple, and it's likely you won't need to such tests if
0
 your controllers are as simple as ours. But once you have more than a few lines

Comments

    No one has commented yet.