public
Description: A Rails plugin to create tests for you when your app throws an unhandled exception
Homepage: http://www.culann.com/2008/03/and-the-greatest-of-these-is-laziness
Clone URL: git://github.com/bscofield/laziness.git
update README to reflect RSpec additions
bscofield (author)
Fri Mar 21 05:23:06 -0700 2008
commit  750a59d382be8962ee05c6092596d702271ffe07
tree    2e0f83d63deea6f2def0ef614c0a463f3ed1609a
parent  e4e2717dd96558e00939cdb65a04da957384cb94
0
...
1
2
3
4
 
5
 
 
 
 
6
7
8
9
10
11
12
 
13
14
 
15
16
17
18
19
 
 
 
 
 
 
 
 
 
 
 
20
...
1
2
3
 
4
5
6
7
8
9
10
11
12
13
14
15
 
16
17
 
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
0
@@ -1,20 +1,35 @@
0
 Laziness
0
 ========
0
 
0
-Laziness does one thing: if your application throws an unhandled error, it will automatically create a failing test for you to copy into the appropriate test file.
0
+Laziness does one thing: if your application throws an unhandled error, it will automatically create a failing test for you to copy into the appropriate test file - or if you're using RSpec, it'll write the appropriate spec for you.
0
 
0
+Installation
0
+============
0
+
0
+If you're running ExceptionNotifier, you'll need to make sure that vendor/plugins/laziness/views/_laziness.rhtml is copied into vendor/plugins/exception_notification/views/exception_notifier - that will allow your exception notifier emails to include the generated test (or spec). The file is normally copied over by the plugin installation process, but if it doesn't make it there you can move it by hand.
0
 
0
 Example
0
 =======
0
 
0
 Say you're browsing your site and you get a 500 error on /users/new, which is rendering the UsersController#new action. In the error page (or exception email, if you're using ExceptionNotifier), Laziness adds something like the following:
0
 
0
-def test_lazy_test_for_users_new_should_not_throw_nameerror_exception
0
+def test_get_users_new_should_not_raise_nameerror_exception
0
   assert_nothing_raised(NameError) do
0
- get :new, {[params from request]}, {[session from request]}, {[flash from request]}, {[cookies from request]}
0
+ get :new, {[params from request]}, {[session from request]}, {[flash from request]}
0
   end
0
 end
0
 
0
 The exact exception asserted (in this case, NameError) will depend on what caused the 500 error in the first place.
0
 
0
+If you're using RSpec, the generated code will look like this:
0
+
0
+describe "Handling GET users new" do
0
+ it "should not raise NameError" do
0
+ lambda {
0
+ get :new, {[params from request]}, {[session from request]}, {[flash from request]}
0
+ }.should_not raise_error(NameError)
0
+ end
0
+end
0
+
0
+
0
 Copyright (c) 2008 Ben Scofield, released under the MIT license
0
...
1
2
3
 
4
...
 
1
2
3
4
0
@@ -1,3 +1,3 @@
0
-- produce specs for RSpec projects
0
 - add tests for the plugin
0
 - documentation
0
+- set cookies in the test
0
\ No newline at end of file

Comments

    No one has commented yet.