æè¡é¨ã»éçºåºç¤ã°ã«ã¼ãã®ä¸æã§ãã
ãã®åº¦ãã¯ãã¯ããããéçºãããªã¼ãã³ã½ã¼ã¹ã¨ãã¦å ¬éãã¦ããRuby on Railsåããããã¿ã¤ãéçºç¨ã®ãã©ã°ã¤ã³ãChankoããåè¨è¨ããRuby 2.0.0 ã¸ã®ç§»è¡ã«å¼ãç¶ã Chanko 2.0.0 ããªãªã¼ã¹ãã¾ãããChanko 2.0.0 ã§ã¯ãããã¾ã§ã®ãã¼ã¸ã§ã³ã¨äºææ§ãä¿ã¡ãªããã主ã«å®è¡é度ãã³ã¼ãã®å¯èªæ§ã«ã¤ãã¦æ¹åãå ãããã¦ãã¾ãã
http://cookpad.github.io/chanko/
Chankoã¨ã¯
Chankoã¯ãç´ æ©ãå®å ¨ã«æ°æ©è½ã®ãããã¿ã¤ããè¡ãããã®ãã¬ã¼ã ã¯ã¼ã¯ã§ããã¯ãã¯ãããã§ã¯ä»ç¾å¨ã§ããChankoã使ã£ã¦å¤ãã®æ©è½ãç¬ç«ãã¦éçºãã対象ç¯å²ãéå®ãã¦å ¬éãããã¨ã§æ°æ©è½ã®æ¤è¨¼ãµã¤ã¯ã«ãåãã¦ãã¾ããChankoãå©ç¨ãã¦æ¡å¼µããæ©è½ã§ã¨ã©ã¼ãèµ·ããå ´åãæ¡å¼µåã®æ©è½ã«èªåçã«åãæ¿ããããããããããã¿ã¤ãã§ã®æ¤è¨¼æ®µéããå®å ¨ã«æ©è½ãæä¾ãããã¨ãåºæ¥ã¦ãã¾ããRailsConf 2012ã§çºè¡¨ããChankoã«ã¤ãã¦ã®ãã¬ã¼ã³è³æãããã¾ãã®ã§ãä½µãã¦ãã¡ããã覧ãã ããã
https://speakerdeck.com/mrkn/chanko
æ¹åã®çµç·¯
ã¯ãã¯ãããã§ã¯ããµã¼ãããã®ã¬ã¹ãã³ã¹ã¿ã¤ã ã«ã¤ãã¦200ms以ä¸ã¨ããç®æ¨ãç½®ãã¦ãã¾ããããã§ãµã¤ãã®ããã©ã¼ãã³ã¹åä¸ã®ããã®åãçµã¿ã¨ãã¦ãéçºè å ¨å¡ã§é度æ¹åã競ãåãããã©ã¼ãã³ã¹ã»ãã¥ã¼ãã³ã¬ã½ã³ã¨ããã¤ãã³ããè¡ãã¾ãããä»åã®Chankoã®æ¹åã¯ããã®ä¸ç°ã§é度ã¨ä¿å®æ§ã®åä¸ãçãã¨ãã¦åãçµãã ãã®ã§ãã
éçºã®é²ãæ¹
ã³ã¼ãã®é度æ¹åãå質åä¸ãç®çã¨ãã¦è¡ãå ´åãçããã©ã®ãããªææ³ã§åãçµã¾ãã¦ããã§ãããããä»åã®æ¹åã«ããã£ã¦ã¯ãè¨æ¸¬ãããã¨ã»æ¤è¨¼ãããã¨ã®äºç¹ãå®ããªããéçºãé²ãã¾ãããéçºã«ããã£ã¦å©ç¨ãããã¼ã«ããµã¼ãã¹ãå¹¾ã¤ãç´¹ä»ãã¾ãã
ruby-prof
é度ä½ä¸ã®åå ã«ãªã£ã¦ããé¨åã調ã¹ããããRubyç¨ã®ãããã¡ã¤ã©ãå©ç¨ãã¦èª¿æ»ãè¡ãã¾ãããRubyã«ã¯æ¨æºæ·»ä»ã©ã¤ãã©ãªã¨ãã¦profileã¨ãããããã¡ã¤ã©ãç¨æããã¦ãã¾ãããããå®è¡é度ã®éã ruby-profãå©ç¨ãã¾ããããããå©ç¨ãã¦ã¡ã½ããå¼åºåæ°ã¨åä½å®è¡æéãè¨æ¸¬ãããã¨ã§ãé度ä½ä¸ã®åå ã«ãªã£ã¦ããããªç®æã«å¤§ã¾ããªäºæ¸¬ãä»ãã¾ããã大æµã®å ´åãå ¨ä½ã®ä¸ã§å®è¡æéãå¤ãå ãã¦ããç®æã¨ããã®ã¯ä¸é¨ã«åã£ã¦ãããããããã§å¤§ä½ã®å½ãããã¤ãããã¨ãã§ãã¾ãã
Travis CI
Travis CIãå©ç¨ãã¦ç¶ç¶çã«ãã¹ããè¡ããªããéçºãé²ãã¾ããããåç¥ã®æ¹ãå¤ããã¨æãã¾ãããTravis CIã¯ãªã¼ãã³ã½ã¼ã¹ã³ãã¥ããã£ã®ããã®ç¶ç¶çã¤ã³ãã°ã¬ã¼ã·ã§ã³ãµã¼ãã¹ã§ããChankoã§ã¯ãruby 1.8ã1.9ãããã¦2.0ã§ç¶ç¶çã«ãã¹ããåããã¨ã§ã常ã«ãã¹ãããã¼ã¸ã§ã³éã®äºææ§ãæèããéçºãè¡ããã¨ãåºæ¥ã¾ãããã¾ãå¹¾ã¤ãã®ä»ã®ãµã¼ãã¹ã¨é£æºããããã¨ã§ãæ´ã«Travis CIã便å©ã«ä½¿ããã¨ãåºæ¥ã¾ãã
Coveralls
ä»åã®æ¹åã«ããããä¿å®æ§ã®é«ãã³ã¼ãã«ããã¨ãããã¨ãç®çã®1ã¤ã¨ãã¦ãã¾ãããããã§ãã¾ãã¯ãã¹ãã®C0ã«ãã¬ãã¸ã100%ã«ããå¾ããã®ç¶æ ããã«ãã¬ãã¸ãè½ã¨ããªãããã«éçºãé²ãã¾ããããããæ¯æ´ããããã®ãµã¼ãã¹ã¨ãã¦ãCoverallsãããã¾ããCoverallsãå©ç¨ããã¨Travis CIã¨é£æºãã¦ãã¹ãå®äºæã«ã«ãã¬ãã¸ãè¨é²ã»éç¥ãã¦ãããããã常ã«ãã¹ãã«ãã¬ãã¸ã®å¤ãæèãã¦éçºãé²ãããã¾ãã
Code Climate
ã³ã¼ãã®å質ã«ã¤ãã¦ãããã¯ãä½ããã®ææ¨ãæã£ã¦æ¹åãã¦ããããã¨ããã§ããä»åã¯Code Climateã®å¤ãææ¨ã¨ãã¦åèã«ãã¾ãããCode Climateã§ã¯ãã³ã¼ãã®éè¤ãè¤é度ãã¡ã½ãããã¨ã®è¡æ°ãªã©ãå ã«ãã³ã¼ãã«ç¹æ°ãã¤ãã¦ããã¾ããChankoã®è©ä¾¡çµæãè¦ãã¨ãä»åã®æ¹åã®åå¾ã§ç¹æ°ãåä¸ãã¦ãããã¨ãåããã¾ãã
Badge
ããã§ç´¹ä»ããTravis CIãCoverallsãCode Climateã®ãµã¼ãã¹ã§ã¯ããããã常ã«ææ°ã®CIã®çµæã表示ãã¦ããããã®ç»åãæä¾ããã¦ãã¾ããæè¿ã§ã¯GitHubä¸ã§è¦ããããã¨ãå¤ããªã£ã¦ãã¾ããããããã®ç»åãREADMEçã«è¡¨ç¤ºãã¦ãããã¨ã§ãããæ¹åæèãé«ãã¦ãããã¨ãåºæ¥ãã¨æãã¾ãã
æ¤è¨¼æ¹æ³
é度ã®æ¤è¨¼ã§ã¯ãã¾ãApache Benchãå©ç¨ãã¦æå ã®ãµã¼ãç°å¢ã§ç°¡åã«æ¤è¨¼ããå¾ãApache JMeterãå©ç¨ãã¦æ¬çªã«è¿ãå½¢ã§ã®ãªã¯ã¨ã¹ãã®ãã¹ããè¡ãã¾ããããã¹ãã«ä½¿ããªã¯ã¨ã¹ãå 容ãå®éã®ã¦ã¼ã¶ããã®ãã®ãæ³å®ããæ¬çªç°å¢ã§åããããµã¼ããã°ãå ã«çæãããã®ãå©ç¨ããé度æ¤è¨¼ã®çµæãã¯ãã¯ãããã®PCããããã¼ã¸ã®å¹³åå¿çæéãç´94.5%ã«åä¸ããã¨ããçµæã«ãªãã¾ãããå°ãªãå¤ã®ããã«è¦ãã¾ãããä¾ãã°æ¹ååã«200msããã£ã¦ããå¿çæéããæ¹åå¾ã§ã¯189msã«ãªãã¾ãã
ãã1ã¤ãä»åã®éçºã§ã¯æ¹ååå¾ã§å®è¡çµæãå¤ãã£ã¦ãã¾ããªãããã«ç¹ã«æ°ãä»ããå¿ è¦ãããã¾ãããããã§æ¬çªç°å¢ã®ãªã¯ã¨ã¹ããkageã使ã£ã¦è¤è£½ããæ°æ§Chankoãå©ç¨ããåçã®ãµã¼ããããããç¨æãã¦ãªã¯ã¨ã¹ããåãåããã¬ã¹ãã³ã¹çµæãæ¯è¼ããã¨ãã£ãæ¤è¨¼ãè¡ãã¾ããã
ã¾ãããã¹ãå®è¡æã«çæãããHTMLãæ°æ§Chankoã§ä¿åãã両è ã®å·®åãæ¯è¼ããã¨ãããã¨ãæ¤è¨¼ã®ææã¨ãã¦å©ç¨ãã¾ãããå ·ä½çã«ã¯ãRSpecã®å®è¡æã«ä¸è¨ã®ãããªã³ã¼ããå©ç¨ãã¦controller specsã¨feature specsã§çæãããã¬ã¹ãã³ã¹ã®ä¸èº«ããã¡ã¤ã«ã«æ¸ãåºãã¦ãããdiffãå©ç¨ãã¦å·®åã調ã¹ã¾ããã
# Write all response bodies into specified directory # # Examples # # $ RESPONSE_BODY_WRITER_DIR=/path/to/dir rspec spec/controllers/entries_controller_spec.rb # # (e.g. the following files are created as a result.) # /path/to/dir/spec/controllers/entries_controller_spec-2.html # /path/to/dir/spec/controllers/entries_controller_spec-5.html # /path/to/dir/spec/controllers/entries_controller_spec-8.html # if ENV["RESPONSE_BODY_WRITER_DIR"] RSpec.configure do |config| config.include( Module.new do def write_response_body target = response || page if target.body.present? pathname = Pathname.new("#{ENV['RESPONSE_BODY_WRITER_DIR']}/#{example.location.gsub(?:, ?-)}.html") pathname.parent.mkpath pathname.open("w") {|file| file.puts target.body } end rescue warn "Something went wrong in the process of #write_response_body after hook" end end ) config.after(:each, :type => :controller) { write_response_body } config.after(:each, :type => :feature) { write_response_body } end end
ã¾ã¨ã
ãã®ããã«ãè¨æ¸¬ã¨æ¤è¨¼ãå¾¹åºãã¦è¡ããªããæ¹åãã¦ãããã¨ã§ãChankoã¯å®å ¨ãã¤çå®ã«éçºãé²ãããã¨ãåºæ¥ã¾ãããçµæã¨ãã¦ããµã¤ãå ¨ä½ã®ã¬ã¹ãã³ã¹ã¿ã¤ã åä¸ã«ç¹ãããã³ã¼ãã®å質åä¸ã«ãè²¢ç®ã§ãã¾ããã
ã¯ãã¯ãããã¯ããªã¼ãã³ã½ã¼ã¹ã³ãã¥ããã£ã«å¯¾ãã¦ç©æ¥µçã«è²¢ç®ãã¦ããããã¨èãã¦ãã¾ãã社å ã§éçºãããã©ã¤ãã©ãªããã¼ã«ãåãåºãã¦ãªã¼ãã³ã½ã¼ã¹åããã¾ããªã¼ãã³ã½ã¼ã¹ããã¸ã§ã¯ãã«ã³ãããããã¨è¨ã£ãåãçµã¿ããä»å¾ãããæ´»çºã«ç¶ãã¦ããããã¨æãã¾ãã