Rails automatic test driven development
Upcoming SlideShare
Loading in...5

Like this? Share it with your network


Rails automatic test driven development



Rails automatic test driven development

Rails automatic test driven development



Total Views
Views on SlideShare
Embed Views



10 Embeds 3,715

http://techparty.org 3590
http://www.techparty.org 66
http://blog.baozishan.in 21
http://feed.feedsky.com 21
http://xianguo.com 5
http://gztp.jeffjie.webfactional.com 3
http://techparty.jeffkit.com 3
http://cache.baidu.com 3
http://webcache.googleusercontent.com 2
http://www.hanrss.com 1



Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

Rails automatic test driven development Presentation Transcript

  • 1. Rails Automatic Test Driven Development• About the author• Test Driven Development• Testing for Rails• RSpec & Capybara• Spork & Guard• Test inside Sublime Text• Show time• References• Q&A
  • 2. About the author• Tyler Long (龙泰勒)• 6 years of software development experience• 2 years as Senior Software Development Manager• Home page: http://tylerlong.me• Weibo.com: @龙泰勒• Github: https://github.com/tylerlong• Bitbucket: https://bitbucket.org/tylerlong
  • 3. Test Driven Development - 1• Three laws of TDD – First Law: You may not write production code until you have written a failing unit test. – Second Law: You may not write more of a unit test than is sufficient to fail, and not compiling is failing. – Third Law: You may not write more production code than is sufficient to pass the current failing test.
  • 4. Test Driven Development - 2• The TDD Cycle – We first write a failing test, represented in many testing tools by the color red. – We then implement code to get the test to pass, represented by the color green. – Finally, if necessary, we refactor the code, changing its form without changing its function. – This cycle is known as “Red, Green, Refactor”.
  • 5. Testing for Rails• Test::Unit – lightweight and straightforward• RSpec (my choice) – has a lot of stuff which makes testing easier• Cucumber – good for making sure all these sort of high-level features and functionalities are covered
  • 6. RSpec & Capybara• RSpec – RSpec is designed to make Test-Driven Development a productive and enjoyable experience – http://rspec.info/• Capybara – Capybara makes it easy to simulate how a user interacts with your application. – http://jnicklas.github.com/capybara/
  • 7. Spork & Guard• Spork – A DRb server for testing frameworks (RSpec / Cucumber currently) that forks before each run to ensure a clean testing state. – https://github.com/sporkrb/spork• Guard – Guard is a command line tool to easily handle events on file system modifications – https://github.com/guard/guard
  • 8. Test inside Sublime Text• Sublime Text – Sublime Text is a sophisticated text editor for code, html and prose. – I switched from Vim to Sublime Text• Run tests directly inside the editor, doesn’t it sound cool? – https://github.com/maltize/sublime-text-2-ruby- tests
  • 9. Show Time - 1
  • 10. Show Time - 2
  • 11. References• Ruby on Rails Tutorial: http://ruby.railstutorial.org/chapters/static- pages?version=3.2• The true meaning of TDD: http://tylerlong.me/1331043344/• Rails TDD (In Chinese): http://tylerlong.me/1332078416/
  • 12. Q&A• Any Questions?