[本文将从下面几个方面,来阐述使用Rspec的好处 * 对于代码块的测试 * 强大的测试helpers支持 * 简洁友好的输出 * 固定格式的测试结果输出 希望,你看完这些
RSpec is the king of the BDD hill when it comes to Rails, and the learning curve is quite steep. For Windows developers hooked on CHM documentation, it’s very easy to generate RSpec CHM files by running the command
rdoc -f chm -o chm_folder rspec*
directory of your RoR project where you have installed the RSpec and RSpec on Rails plugins using
ruby script/plugin install http://rspec.rubyforge.org/svn/tags/CURRENT/rspec
ruby script/plugin install http://rspec.rubyforge.org/svn/tags/CURRENT/rspec_on_rails
as described on the RSpec home page .
The resulting CHM is not the prettiest but it’s fully searchable and easier to use than sifting through the online rdocs in your browser.
Update December 5, 2008 : RSpec is under heavy development, and installation instructions change frequently, so you should always refer to the rspec home page for details.
RSpec and RSpec for Rails are now gems only so to generate the chm file cd to your gems directory (usually C:\ruby\lib\ruby\gems\1.8\gems), which you can determine by running
at the command prompt, and then run
rdoc -f chm -o chm_folder rspec* -x helper_spec.rb
helper_rspec.rb has to be excluded as it causes the rdoc generation to hang. Here’s the updated resulting chm file for rspec , raw and unedited.
P.S.: This only works on Windows as it depends on HTML Help Workshop but the chm file can be viewed with other chm viewers. I recommend xCHM for Linux .