rcovã使ã
rcov?
rcovã¯ã³ã¼ãã«ãã¬ãã¸ãè¨æ¸¬ãããã¼ã«ã§ããã¹ããæ¸ãã¦ããã¨åããããæ©æµã®ã²ã¨ã¤ãJavaã使ã£ã¦ããã¨ãã«ãåæ§ã®ãã¼ã«ã§ããcoverturaã«åºä¼ã£ã¦ãããã¯ãããã¨æã£ããªãã
rcovã®ã¤ã³ã¹ãã¼ã«
ä»åã¯ãä¸è¨ã®ãµã¤ããåèã«ããã
railsããã¸ã§ã¯ãã®Gemfileã«ãrcovã追å ãã
Gemfile
gem "rcov"
rcovãã¤ã³ã¹ãã¼ã«ããããã«ãbundleãå®è¡ãã
$ bundle install
rcovãå®è¡ãã
$ rake spec:rcov
æ¥æ¬èªãå
¥ã£ã¦ããå ´åããinvalid byte sequence in US-ASCII (ArgumentError)ããçºçããã
ãã®å¯¾å¿ã¨ãã¦ãä¸è¨ã®spec_helper.rbã«ä¸è¨ã®ã³ã¼ãã追å ããã¨è§£æ±ºããã
spec/spec_helper.rb
# # quick monkey patch for rcov # # http://codefluency.com/post/1023734493/a-bandaid-for-rcov-on-ruby-1-9 # if defined?(Rcov) class Rcov::CodeCoverageAnalyzer def update_script_lines__ if '1.9'.respond_to?(:force_encoding) SCRIPT_LINES__.each do |k,v| v.each { |src| src.force_encoding('utf-8') } end end @script_lines__ = @script_lines__.merge(SCRIPT_LINES__) end end end
å度å®è¡ããã¨æ£å¸¸ã«çµäºããã¯ãã
rcovã®çµæãè¦ã
rcovãå®è¡ããã¨ãrailsããã¸ã§ã¯ãã®ç´ä¸ã«coverageã¨ãããã£ã¬ã¯ããªãä½æããã¦ããã
ãã®ä¸ã®index.htmlããã©ã¦ã¶ã§éãã¨ãã«ãã¬ãã¸ãè¦ããã