'rvm 'monitor' - monitoring tests with RVM
RVM monitor provides a way to monitor test::unit,shoulda,rspec etc... for changes and run specs/tests that have changed when files change. Let's check out two examples of using this.
For the first example I will use the extlib project. First start up RVM monitor and then in my editor I change the files spec/array_spec.rb spec/blank_spec.rb and save them both at the same time.
rvm 1.8.6,1.8.7,1.9.1 monitor wayne@Genius ~/projects/ruby/extlib [git:master] (0) ∴ rvm 1.8.6,1.8.7,1.9.1,jruby monitor ruby-1.8.6-p383: ruby 1.8.6 (2009-08-04 patchlevel 383) [i686-darwin10.2.0] Profiling enabled. ...................... Top 10 slowest examples: 0.0003950 Array#to_hash should return a Hash 0.0003630 Array#to_mash should return a Mash 0.0002400 String should be blank if it only contains whitespace 0.0001840 Object should not be blank if not nil or empty 0.0001620 FalseClass should always be blank 0.0001380 Array should respond to #to_hash 0.0001290 Object should be blank if it is empty 0.0001280 Object should be blank if it is nil 0.0000950 Numeric should never be blank 0.0000910 String should not be blank if it contains non-whitespace Finished in 0.006417 seconds 22 examples, 0 failures ruby-1.8.7-p174: ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.2.0] Profiling enabled. ...................... Top 10 slowest examples: 0.0003670 Array#to_hash should return a Hash 0.0003240 Array#to_mash should return a Mash 0.0001880 Object should not be blank if not nil or empty 0.0001630 Array should respond to #to_hash 0.0001350 String should be blank if it only contains whitespace 0.0001350 Object should be blank if it is empty 0.0001260 Object should be blank if it is nil 0.0000950 String should not be blank if it contains non-whitespace 0.0000950 String should be blank if empty 0.0000930 NilClass should always be blank Finished in 0.006512 seconds 22 examples, 0 failures ruby-1.9.1-p243: ruby 1.9.1p243 (2009-07-16 revision 24175) [i686-darwin10.2.0] Profiling enabled. ...................... Top 10 slowest examples: 0.0002390 Array#to_hash should return a Hash 0.0002250 NilClass should provide blank? 0.0002040 Array#to_mash should return a Mash 0.0001740 String should provide blank? 0.0001560 Array should respond to #to_hash 0.0001460 String should be blank if it only contains whitespace 0.0001380 Object should not be blank if not nil or empty 0.0001210 String should be blank if empty 0.0001110 String should not be blank if it contains non-whitespace 0.0001080 TrueClass should never be blank Finished in 0.028875 seconds 22 examples, 0 failures
For a second example I will use the coulda project. This one uses shoulda for its tests. I first start RVM monitor and then change the files test/feature_test.rb test/integration/using_coulda_test.rb in my editor and save both at the same time.
∴ rvm 1.8.6,1.8.7,1.9.1 monitor ruby-1.8.6-p383: ruby 1.8.6 (2009-08-04 patchlevel 383) [i686-darwin10.2.0] Loaded suite test/test_helper Started ................. Finished in 0.005337 seconds. 17 tests, 12 assertions, 0 failures, 0 errors ruby-1.8.7-p174: ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.2.0] Loaded suite test/test_helper Started ................. Finished in 0.006245 seconds. 17 tests, 12 assertions, 0 failures, 0 errors ruby-1.9.1-p243: ruby 1.9.1p243 (2009-07-16 revision 24175) [i686-darwin10.2.0] Loaded suite test/test_helper Started ................. Finished in 0.008412 seconds. 17 tests, 12 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed
Notes
RVM monitor currently runs individual files that have changed only and does not re-run on fail repetitively. It simply runs and reports the results of your changes and stops there. Currently if you wish to run all specs you would not use monitor, for that you would use the rake do action.
∴ rvm 1.8.6,1.8.7,1.9.1 rake spec # or ∴ rvm 1.8.6,1.8.7,1.9.1 rake test # or ∴ rvm 1.8.6,1.8.7,1.9.1 specs # or ∴ rvm 1.8.6,1.8.7,1.9.1 tests