Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 41 lines (27 sloc) 1.947 kb
0b1d51bc »
2008-03-19 adding the laziness plugin - initial import
1 Laziness
2 ========
3
750a59d3 »
2008-03-21 update README to reflect RSpec additions
4 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.
0b1d51bc »
2008-03-19 adding the laziness plugin - initial import
5
750a59d3 »
2008-03-21 update README to reflect RSpec additions
6 Installation
7 ============
8
9 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.
0b1d51bc »
2008-03-19 adding the laziness plugin - initial import
10
11 Example
12 =======
13
3eed6ba1 »
2008-03-20 update the README example
14 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:
0b1d51bc »
2008-03-19 adding the laziness plugin - initial import
15
750a59d3 »
2008-03-21 update README to reflect RSpec additions
16 def test_get_users_new_should_not_raise_nameerror_exception
3eed6ba1 »
2008-03-20 update the README example
17 assert_nothing_raised(NameError) do
750a59d3 »
2008-03-21 update README to reflect RSpec additions
18 get :new, {[params from request]}, {[session from request]}, {[flash from request]}
0b1d51bc »
2008-03-19 adding the laziness plugin - initial import
19 end
20 end
21
3eed6ba1 »
2008-03-20 update the README example
22 The exact exception asserted (in this case, NameError) will depend on what caused the 500 error in the first place.
0b1d51bc »
2008-03-19 adding the laziness plugin - initial import
23
750a59d3 »
2008-03-21 update README to reflect RSpec additions
24 If you're using RSpec, the generated code will look like this:
25
26 describe "Handling GET users new" do
27 it "should not raise NameError" do
28 lambda {
29 get :new, {[params from request]}, {[session from request]}, {[flash from request]}
30 }.should_not raise_error(NameError)
31 end
32 end
33
e9fac635 »
2008-03-29 update README wrt handling specific exceptions
34 Catching Specific Exceptions
35 ============================
36
6a04d53b »
2008-04-18 update README for new approach
37 You can customize the tests to be generated on an exception-by-exception basis; just add the appropriate file to lib/exceptions/what/ever.rb and make sure it defines ++test++ and ++spec++ methods; look at lib/exceptions/action_controller/unknown_view.rb for an example.
e9fac635 »
2008-03-29 update README wrt handling specific exceptions
38
750a59d3 »
2008-03-21 update README to reflect RSpec additions
39
0b1d51bc »
2008-03-19 adding the laziness plugin - initial import
40 Copyright (c) 2008 Ben Scofield, released under the MIT license
Something went wrong with that request. Please try again.