SlideShare a Scribd company logo
Testing in Ruby
Testing in Ruby
By Pavel Shutin. April 2013
Testing in Ruby
Pavel Shutin
• https://github.com/pluff
• http://linkedin.com/pub/pavel-shutin/56/440/168
• http://www.facebook.com/pavel.shutin
• publicshady@gmail.com
By Pavel Shutin. April 2013
Testing in Ruby
Test Types
http://tiny.cc/0m0luw
•Functional
•Security
•Performance
•Recovery
•Regression
By Pavel Shutin. April 2013
Testing in Ruby
Manual Testing
http://tiny.cc/tk1luw
http://tiny.cc/9l1luw
•People are slow
•People can fail
•Manual testing applies to more-a-less
finished system
By Pavel Shutin. April 2013
Testing in Ruby
Automated Testing
•Fast!
•Doesn't have human mistake factor
•Allows to test at any point in time.
•Gives an ability to quickly verify that you
didn't broke anything!
By Pavel Shutin. April 2013
Testing in Ruby
Too good to be true!
•Complex usecases require a lot of time to
represent in code.
•Frequently changing pieces of code
require too much effort to maintain all
tests.
By Pavel Shutin. April 2013
Testing in Ruby
Take best of both worlds
•Use automation for all criticalimportant
parts of application
•Use automation everywhere where its
reasonable
•Let your real users to test the rest
By Pavel Shutin. April 2013
Testing in Ruby
Why should developers write tests?
•Make sure you did the right thing!
•Enforce yourself to do things right!
•Make sure nobody will break it!
•Catch any errors as soon as possible.
By Pavel Shutin. April 2013
Testing in Ruby
Testing tools in Ruby
• Minitest
• Rspec
• Cucumber
• Capybara
• FactoryGirl
By Pavel Shutin. April 2013
Testing in Ruby
Test structure
By Pavel Shutin. April 2013
Testing in Ruby
Test hooks & Lazy variables
By Pavel Shutin. April 2013
Testing in Ruby
TDD
Write tests as requirements to future code.
Ensure tests are failing
Write code until tests are green
Review the code for refactoring
Don't write a single line of code anymore!
By Pavel Shutin. April 2013
Testing in Ruby
By Pavel Shutin. April 2013
Testing in Ruby
Stubs
http://tiny.cc/0v1tuw
By Pavel Shutin. April 2013
Testing in Ruby
Mocks
http://tiny.cc/zs1tuw
By Pavel Shutin. April 2013
Testing in Ruby
To stub or not to stub?
•Implementation matters? You can use
stubs!
•Don't test the code you didn't write. Mock
it!
•You can test libraries too to ensure valid
interface.
•Really heavy method? Stub it.
By Pavel Shutin. April 2013
Testing in Ruby
Cucumber and BDD
http://tiny.cc/hq1tuw
Given that a customer buys a blue garment
And I have two blue garments in stock
And three black garments in stock.
When he returns the garment for a replacement in
black,
Then I should have three blue garments in stock
And two black garments in stock
By Pavel Shutin. April 2013
Testing in Ruby
F.I.R.S.T.
http://tiny.cc/e81tuw
•Fast (10 tests per second at least)
•Isolated (no reverse engineering)
•Repeatable (no randoms, no traces)
•Self-validated (passed/failed only)
•Timely (tests before code)
By Pavel Shutin. April 2013
Testing in Ruby
Rubyist Library
1. The Ruby Programming Language
2. Metaprogramming Ruby: Program Like the Ruby
Pros
3. The Pragmatic Programmer: From Journeyman
to Master
4. The Mythical Man-Month: Essays on Software
Engineering
5. Code Complete: A Practical Handbook of
Software Construction
By Pavel Shutin. April 2013
Testing in Ruby
Questions?
By Pavel Shutin. April 2013
Testing in Ruby
Thank you and Happy Testing
By Pavel Shutin. April 2013

More Related Content

PPT
Hacking on gems
PDF
Rubyslava debugging with_pry
PDF
Can you TDD Rails?
PDF
Git in the Van HighEdWeb 2013
PDF
team++; making your team work better together
PPTX
Test Driven Development on Android (Kotlin Kenya)
PDF
Come si applica l'OCP
PDF
TDD on android. Why and How? (Coding Serbia 2019)
Hacking on gems
Rubyslava debugging with_pry
Can you TDD Rails?
Git in the Van HighEdWeb 2013
team++; making your team work better together
Test Driven Development on Android (Kotlin Kenya)
Come si applica l'OCP
TDD on android. Why and How? (Coding Serbia 2019)

What's hot (8)

PPTX
'IS THERE JAVASCRIPT ON SWAGGER PLUGINS?' by Dmytro Gusev
PDF
TDD super mondays-june-2014
PDF
End-to-end performance testing, profiling, and analysis at Redis
PPT
Test Motherfucker...Test
PDF
Conversational Development
PDF
Remote and Open: How GitLab functions (presentation at Landing.careers)
PDF
Beyond Agile: Conversational Development
PDF
Vinted life embetterment
'IS THERE JAVASCRIPT ON SWAGGER PLUGINS?' by Dmytro Gusev
TDD super mondays-june-2014
End-to-end performance testing, profiling, and analysis at Redis
Test Motherfucker...Test
Conversational Development
Remote and Open: How GitLab functions (presentation at Landing.careers)
Beyond Agile: Conversational Development
Vinted life embetterment
Ad

Recently uploaded (20)

PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
A Presentation on Artificial Intelligence
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Machine Learning_overview_presentation.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Encapsulation theory and applications.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Spectroscopy.pptx food analysis technology
Advanced methodologies resolving dimensionality complications for autism neur...
Programs and apps: productivity, graphics, security and other tools
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Network Security Unit 5.pdf for BCA BBA.
20250228 LYD VKU AI Blended-Learning.pptx
A Presentation on Artificial Intelligence
Encapsulation_ Review paper, used for researhc scholars
Machine Learning_overview_presentation.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
NewMind AI Weekly Chronicles - August'25-Week II
MYSQL Presentation for SQL database connectivity
Diabetes mellitus diagnosis method based random forest with bat algorithm
Encapsulation theory and applications.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Digital-Transformation-Roadmap-for-Companies.pptx
Empathic Computing: Creating Shared Understanding
Spectroscopy.pptx food analysis technology
Ad

Bsu on rails_testing

  • 1. Testing in Ruby Testing in Ruby By Pavel Shutin. April 2013
  • 2. Testing in Ruby Pavel Shutin • https://github.com/pluff • http://linkedin.com/pub/pavel-shutin/56/440/168 • http://www.facebook.com/pavel.shutin • publicshady@gmail.com By Pavel Shutin. April 2013
  • 3. Testing in Ruby Test Types http://tiny.cc/0m0luw •Functional •Security •Performance •Recovery •Regression By Pavel Shutin. April 2013
  • 4. Testing in Ruby Manual Testing http://tiny.cc/tk1luw http://tiny.cc/9l1luw •People are slow •People can fail •Manual testing applies to more-a-less finished system By Pavel Shutin. April 2013
  • 5. Testing in Ruby Automated Testing •Fast! •Doesn't have human mistake factor •Allows to test at any point in time. •Gives an ability to quickly verify that you didn't broke anything! By Pavel Shutin. April 2013
  • 6. Testing in Ruby Too good to be true! •Complex usecases require a lot of time to represent in code. •Frequently changing pieces of code require too much effort to maintain all tests. By Pavel Shutin. April 2013
  • 7. Testing in Ruby Take best of both worlds •Use automation for all criticalimportant parts of application •Use automation everywhere where its reasonable •Let your real users to test the rest By Pavel Shutin. April 2013
  • 8. Testing in Ruby Why should developers write tests? •Make sure you did the right thing! •Enforce yourself to do things right! •Make sure nobody will break it! •Catch any errors as soon as possible. By Pavel Shutin. April 2013
  • 9. Testing in Ruby Testing tools in Ruby • Minitest • Rspec • Cucumber • Capybara • FactoryGirl By Pavel Shutin. April 2013
  • 10. Testing in Ruby Test structure By Pavel Shutin. April 2013
  • 11. Testing in Ruby Test hooks & Lazy variables By Pavel Shutin. April 2013
  • 12. Testing in Ruby TDD Write tests as requirements to future code. Ensure tests are failing Write code until tests are green Review the code for refactoring Don't write a single line of code anymore! By Pavel Shutin. April 2013
  • 13. Testing in Ruby By Pavel Shutin. April 2013
  • 16. Testing in Ruby To stub or not to stub? •Implementation matters? You can use stubs! •Don't test the code you didn't write. Mock it! •You can test libraries too to ensure valid interface. •Really heavy method? Stub it. By Pavel Shutin. April 2013
  • 17. Testing in Ruby Cucumber and BDD http://tiny.cc/hq1tuw Given that a customer buys a blue garment And I have two blue garments in stock And three black garments in stock. When he returns the garment for a replacement in black, Then I should have three blue garments in stock And two black garments in stock By Pavel Shutin. April 2013
  • 18. Testing in Ruby F.I.R.S.T. http://tiny.cc/e81tuw •Fast (10 tests per second at least) •Isolated (no reverse engineering) •Repeatable (no randoms, no traces) •Self-validated (passed/failed only) •Timely (tests before code) By Pavel Shutin. April 2013
  • 19. Testing in Ruby Rubyist Library 1. The Ruby Programming Language 2. Metaprogramming Ruby: Program Like the Ruby Pros 3. The Pragmatic Programmer: From Journeyman to Master 4. The Mythical Man-Month: Essays on Software Engineering 5. Code Complete: A Practical Handbook of Software Construction By Pavel Shutin. April 2013
  • 20. Testing in Ruby Questions? By Pavel Shutin. April 2013
  • 21. Testing in Ruby Thank you and Happy Testing By Pavel Shutin. April 2013