SlideShare a Scribd company logo
Ruby BlocksTest Driven Performance Monitorwith Stubs
BlocksA block is an anonymous function. my_array.each do |value|	do_something(value)end
Performance Monitor Example	How it works:Record TimeRun CodeReport Time DifferenceHmmm… how do we test when time is always changing?
	A Test Double replaces the "real" instance of an object used by the production code with something suitable for the currently running test, but with the same interfaceStubsHard-coded valuesMocksPre-programmed with expectationsFail-fastTest Doubles in general are often called Mock Objects, so be careful about terminologyFakesCan store values across calls, but don't really do what the live object would doE.g. in-memory databaseTest Doubles
How to Test Code with DependenciesExample from The Rspec Book by David Chelimsky
Isolating the SubjectExample from The Rspec Book by David Chelimsky
Stub in RSpecmy_instance.stub!(:msg).and_return(value)MyClass.stub!(:msg).and_return(value)
Stub in RSpecmy_obj.stub!(:msg).and_return("1",2)my_obj.stub!(:msg).and_return { ... }
Stub for Specific Valuesmy_obj.stub!(:msg).with(1).and_return(2)
Stub in RSpecmy_obj.stub!(:msg).and_return { ... }

More Related Content

PPT
Concurrency Patterns
ODP
Small eigen collider
PPTX
Groovy best pratices at EWAY
PPTX
Groovy / comparison with java
PPTX
Asynchronous Programming in .NET
PDF
Elm view
PDF
Back to the future: Isomorphic javascript applications
PPTX
Great APIs
Concurrency Patterns
Small eigen collider
Groovy best pratices at EWAY
Groovy / comparison with java
Asynchronous Programming in .NET
Elm view
Back to the future: Isomorphic javascript applications
Great APIs

What's hot (12)

PPTX
Testing of React JS app
PDF
Turbocharging Client-Side Processing: Leveraging asm.js
PDF
Ruby on rails rspec
PPT
JavaScript Unit Testing
DOC
Qtp quiz for you
PDF
Play Framework
PPTX
Mock cli with Python unittest
PDF
RubyMotion Introduction
PPTX
JavaScript Conditional Statements
PDF
Typescript for the programmers who like javascript
PPTX
Reactive Extensions for JavaScript
PDF
Callable and runnable objects in ruby
Testing of React JS app
Turbocharging Client-Side Processing: Leveraging asm.js
Ruby on rails rspec
JavaScript Unit Testing
Qtp quiz for you
Play Framework
Mock cli with Python unittest
RubyMotion Introduction
JavaScript Conditional Statements
Typescript for the programmers who like javascript
Reactive Extensions for JavaScript
Callable and runnable objects in ruby
Ad

Viewers also liked (8)

PPTX
Mobile Ruby, LA RubyConf
PPTX
Test-Driven Development
PPT
Sarah Allen Ignite 09
PDF
People Patterns or What I learned from Toastmasters
KEY
RailsBridge Presentation
PPTX
Power ruby
PPTX
Ruby Blocks
PPTX
Cross-Platform Mobile Apps with Ruby, MWRC
Mobile Ruby, LA RubyConf
Test-Driven Development
Sarah Allen Ignite 09
People Patterns or What I learned from Toastmasters
RailsBridge Presentation
Power ruby
Ruby Blocks
Cross-Platform Mobile Apps with Ruby, MWRC
Ad

Similar to Ruby Blocks (20)

PPTX
Unit testing
KEY
Agile JavaScript Testing
PPTX
Using Rhino Mocks for Effective Unit Testing
KEY
Ruby Blocks
ODP
Interaction testing using mock objects
PPS
Master in javascript
PPTX
TechDays - IronRuby
PPT
Ruby for C# Developers
PPT
Google mock for dummies
PPT
Google mock for dummies
PPT
Google mock for dummies
PPT
Google mock for dummies
PPT
Google mock for dummies
PPT
Google mock for dummies
PPT
Google mock for dummies
PDF
wtst3_pettichord3
PDF
wtst3_pettichord3
PPTX
Qtp training session IV
PPTX
All of Javascript
PDF
4 JVM Web Frameworks
Unit testing
Agile JavaScript Testing
Using Rhino Mocks for Effective Unit Testing
Ruby Blocks
Interaction testing using mock objects
Master in javascript
TechDays - IronRuby
Ruby for C# Developers
Google mock for dummies
Google mock for dummies
Google mock for dummies
Google mock for dummies
Google mock for dummies
Google mock for dummies
Google mock for dummies
wtst3_pettichord3
wtst3_pettichord3
Qtp training session IV
All of Javascript
4 JVM Web Frameworks

More from Sarah Allen (20)

PDF
Internet security: a landscape of unintended consequences
PPTX
RTMP: how did we get to now? (Demuxed 2019)
PDF
Communication is a Technical Skill
PPTX
Improving Federal Government Services
PPTX
Transparency Wins
PPTX
A Short History of Computers
PPTX
Making Software Fun
PPTX
Power of Transparency
PPTX
Designing for Fun
PDF
Ruby in the US Government for Ruby World Conference
PDF
Identities of Dead People
PDF
Let's pretend
PDF
3 Reasons Not to Use Ruby
PDF
Ruby Nation: Why no haz Ruby?
PDF
Why no ruby in gov?
PDF
Blazing Cloud: Agile Product Development
PDF
Crowdsourced Transcription Landscape
PDF
Lessons Learned Future Thoughts
PDF
Mobile Web Video
PPTX
Elementary Computer History
Internet security: a landscape of unintended consequences
RTMP: how did we get to now? (Demuxed 2019)
Communication is a Technical Skill
Improving Federal Government Services
Transparency Wins
A Short History of Computers
Making Software Fun
Power of Transparency
Designing for Fun
Ruby in the US Government for Ruby World Conference
Identities of Dead People
Let's pretend
3 Reasons Not to Use Ruby
Ruby Nation: Why no haz Ruby?
Why no ruby in gov?
Blazing Cloud: Agile Product Development
Crowdsourced Transcription Landscape
Lessons Learned Future Thoughts
Mobile Web Video
Elementary Computer History

Recently uploaded (20)

PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Modernizing your data center with Dell and AMD
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Electronic commerce courselecture one. Pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Machine learning based COVID-19 study performance prediction
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Spectral efficient network and resource selection model in 5G networks
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Modernizing your data center with Dell and AMD
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Advanced methodologies resolving dimensionality complications for autism neur...
Mobile App Security Testing_ A Comprehensive Guide.pdf
cuic standard and advanced reporting.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Electronic commerce courselecture one. Pdf
MYSQL Presentation for SQL database connectivity
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Machine learning based COVID-19 study performance prediction
NewMind AI Monthly Chronicles - July 2025
NewMind AI Weekly Chronicles - August'25 Week I
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Encapsulation_ Review paper, used for researhc scholars
Spectral efficient network and resource selection model in 5G networks

Ruby Blocks