11require 'test_helper'
22
33class DocumentsControllerTest < ActionController ::TestCase
4+ # standard test
45 test "index" do
56 get :index
67 assert_equal 200 , response . status
78 end
89
10+ # will create a call stack and html graph output
11+ # ruby -I lib:test test/controllers/documents_controller_test.rb -n test_index_rp
912 test "index rp" do
1013 result = RubyProf . profile do
1114 get :index
1215 assert_equal 200 , response . status
1316 end
14- printer = RubyProf ::CallStackPrinter . new ( result )
15- printer . print ( STDOUT , { } )
17+ File . open ( 'graphs/inside_minitest/index_controller_callstack.html' , 'w' ) do |file |
18+ RubyProf ::CallStackPrinter . new ( result ) . print ( file )
19+ end
20+
21+ File . open ( 'graphs/inside_minitest/index_controller_htmlgraph.html' , 'w' ) do |file |
22+ RubyProf ::GraphHtmlPrinter . new ( result ) . print ( file )
23+ end
1624 end
1725
26+ # ruby -I lib:test test/controllers/documents_controller_test.rb -n test_index_flame
1827 test "index flame" do
19- Flamegraph . generate ( "graphs/#{ Time . now } _controller_index .html" ) do
28+ Flamegraph . generate ( "graphs/inside_minitest/index_controller_flamegraph .html" ) do
2029 get :index
2130 assert_equal 200 , response . status
2231 end
2332 end
2433
34+ # standard test
2535 test "create" do
2636 post :create , document : { title : "New things" , content : "Doing them" }
2737
@@ -30,6 +40,7 @@ class DocumentsControllerTest < ActionController::TestCase
3040 assert_equal 'Doing them' , document . content
3141 end
3242
43+ # ruby -I lib:test test/controllers/documents_controller_test.rb -n test_create_rp
3344 test "create rp" do
3445 result = RubyProf . profile do
3546 post :create , document : { title : "New things" , content : "Doing them" }
@@ -38,12 +49,18 @@ class DocumentsControllerTest < ActionController::TestCase
3849 assert_equal 'New things' , document . title
3950 assert_equal 'Doing them' , document . content
4051 end
41- printer = RubyProf ::CallStackPrinter . new ( result )
42- printer . print ( STDOUT , { } )
52+ File . open ( 'graphs/inside_minitest/create_controller_callstack.html' , 'w' ) do |file |
53+ RubyProf ::CallStackPrinter . new ( result ) . print ( file )
54+ end
55+
56+ File . open ( 'graphs/inside_minitest/create_controller_htmlgraph.html' , 'w' ) do |file |
57+ RubyProf ::GraphHtmlPrinter . new ( result ) . print ( file )
58+ end
4359 end
4460
61+ # ruby -I lib:test test/controllers/documents_controller_test.rb -n test_create_flame
4562 test "create flame" do
46- Flamegraph . generate ( "graphs/#{ Time . now } _controller_create .html" ) do
63+ Flamegraph . generate ( "graphs/inside_minitest/create_controller_flamegraph .html" ) do
4764 post :create , document : { title : "New things" , content : "Doing them" }
4865
4966 document = Document . last
0 commit comments