SlideShare a Scribd company logo
1 of 26
Download to read offline
Mockfight!
          FlexMock vs. Mocha
          Patrick Reagan
          patrick@viget.com
          Director, Application Development




Viget Labs
we build web business



July 18, 2007                 © Copyright 2007 Viget Labs, LLC – www.viget.com
Mockfight! FlexMock vs. Mocha                                                      2




What are Mocks?


          “Mock objects are simulated
          objects that mimic the behavior of
          real objects in controlled ways”
                          - Wikipedia


Viget Labs
we build web business



July 18, 2007                   © Copyright 2007 Viget Labs, LLC – www.viget.com
Mockfight! FlexMock vs. Mocha                                                      3




When to Mock?

Use mocks when you want to:

• Control the behavior of internal method calls

• Remove dependence on external systems

• Improve test performance



Viget Labs
we build web business



July 18, 2007                   © Copyright 2007 Viget Labs, LLC – www.viget.com
Mockfight! FlexMock vs. Mocha                                                      4




Control Behavior

What does this return?




Need to maintain consistency between calls

Viget Labs
we build web business



July 18, 2007                   © Copyright 2007 Viget Labs, LLC – www.viget.com
Mockfight! FlexMock vs. Mocha                                                                      5




Control Behavior

How do we test?


                                                                                   Magic happens
                                                                                   here




Stub the call to Die#rand (using Mocha)


Viget Labs
we build web business



July 18, 2007                   © Copyright 2007 Viget Labs, LLC – www.viget.com
Mockfight! FlexMock vs. Mocha                                                      6




Remove Dependencies

Example: retrieve response data via HTTP




To test this, we need to mock:
 • Call to URI#parse
 • Calls to Net::HTTP#new and Net::HTTP#head


Viget Labs
we build web business



July 18, 2007                   © Copyright 2007 Viget Labs, LLC – www.viget.com
Mockfight! FlexMock vs. Mocha                                                      7




Mockfight!

Expanded example:
• Create class method to check for resource
• Handle errors and redirects
• Iteratively develop functionality while testing
• Examine the differences between libraries



Viget Labs
we build web business



July 18, 2007                   © Copyright 2007 Viget Labs, LLC – www.viget.com
Mockfight! FlexMock vs. Mocha                                                      8




Round 1

Test scenario when URI#parse raises exception




Viget Labs
we build web business



July 18, 2007                   © Copyright 2007 Viget Labs, LLC – www.viget.com
Mockfight! FlexMock vs. Mocha                                                      9




Round 1: Results

FlexMock




Mocha




Viget Labs
we build web business



July 18, 2007                   © Copyright 2007 Viget Labs, LLC – www.viget.com
Mockfight! FlexMock vs. Mocha                                                      10




Round 2

Check for a valid response




Viget Labs
we build web business



July 18, 2007                   © Copyright 2007 Viget Labs, LLC – www.viget.com
Mockfight! FlexMock vs. Mocha                                                      11




Round 2: Results

FlexMock




Mocha




Viget Labs
we build web business



July 18, 2007                   © Copyright 2007 Viget Labs, LLC – www.viget.com
Mockfight! FlexMock vs. Mocha                                                      12




Round 3

Check for response type instead of status code




* Our previous tests for response status code are now invalid


Viget Labs
we build web business



July 18, 2007                   © Copyright 2007 Viget Labs, LLC – www.viget.com
Mockfight! FlexMock vs. Mocha                                                      13




Round 3: Results

FlexMock




Mocha




Viget Labs
we build web business



July 18, 2007                   © Copyright 2007 Viget Labs, LLC – www.viget.com
Mockfight! FlexMock vs. Mocha                                                      14




Round 4

Follow an HTTP redirect response




Viget Labs
we build web business



July 18, 2007                   © Copyright 2007 Viget Labs, LLC – www.viget.com
Mockfight! FlexMock vs. Mocha                                                      15




Round 4: Results

FlexMock




Viget Labs
we build web business



July 18, 2007                   © Copyright 2007 Viget Labs, LLC – www.viget.com
Mockfight! FlexMock vs. Mocha                                                      16




Round 4: Results

Mocha




Viget Labs
we build web business



July 18, 2007                   © Copyright 2007 Viget Labs, LLC – www.viget.com
Mockfight! FlexMock vs. Mocha                                                      17




Round 5

Handling maximum number of redirects




Viget Labs
we build web business



July 18, 2007                   © Copyright 2007 Viget Labs, LLC – www.viget.com
Mockfight! FlexMock vs. Mocha                                                      18




Round 5: Results

FlexMock




Viget Labs
we build web business



July 18, 2007                   © Copyright 2007 Viget Labs, LLC – www.viget.com
Mockfight! FlexMock vs. Mocha                                                      19




Round 5: Results

Mocha




Viget Labs
we build web business



July 18, 2007                   © Copyright 2007 Viget Labs, LLC – www.viget.com
Mockfight! FlexMock vs. Mocha                                                      20




Bonus Round

Mocking ActiveRecord#find in controllers




Viget Labs
we build web business



July 18, 2007                   © Copyright 2007 Viget Labs, LLC – www.viget.com
Mockfight! FlexMock vs. Mocha                                                      21




Bonus Round: Results

FlexMock




Mocha




Viget Labs
we build web business



July 18, 2007                   © Copyright 2007 Viget Labs, LLC – www.viget.com
Mockfight! FlexMock vs. Mocha                                                      22




But Wait, There’s More

Mocha has parameter matchers (in SVN)
You can write code like this:




Viget Labs
we build web business



July 18, 2007                   © Copyright 2007 Viget Labs, LLC – www.viget.com
Mockfight! FlexMock vs. Mocha                                                      23




Conclusion


• Newest versions of gems contain similar features

• FlexMock can accept blocks for further mocking

• Personal preference of syntax is the deciding factor



Viget Labs
we build web business



July 18, 2007                   © Copyright 2007 Viget Labs, LLC – www.viget.com
Mockfight! FlexMock vs. Mocha                                                         24




It’s a Tie!




                                Ultimately, two great libraries - just pick one

Viget Labs
we build web business



July 18, 2007                      © Copyright 2007 Viget Labs, LLC – www.viget.com
Mockfight! FlexMock vs. Mocha                                                      25




Questions?




                                                            ???

Viget Labs
we build web business



July 18, 2007                   © Copyright 2007 Viget Labs, LLC – www.viget.com
Mockfight! FlexMock vs. Mocha                                                      26




Additional Information

FlexMock (Jim Weirich)
          http://www.onestepback.org/software/flexmock


Mocha (James Mead)
          http://mocha.rubyforge.org


                         http://www.slideshare.net/viget
Viget Labs
we build web business



July 18, 2007                   © Copyright 2007 Viget Labs, LLC – www.viget.com

More Related Content

More from Viget Labs

9 Tips to Profitability: How Squidoo Did It
9 Tips to Profitability: How Squidoo Did It9 Tips to Profitability: How Squidoo Did It
9 Tips to Profitability: How Squidoo Did ItViget Labs
 
Advanced RESTful Rails
Advanced RESTful RailsAdvanced RESTful Rails
Advanced RESTful RailsViget Labs
 
Cleanliness is Next to Domain-Specificity
Cleanliness is Next to Domain-SpecificityCleanliness is Next to Domain-Specificity
Cleanliness is Next to Domain-SpecificityViget Labs
 
Changing Your Mindset: Getting Started With Test-Driven Development
Changing Your Mindset: Getting Started With Test-Driven DevelopmentChanging Your Mindset: Getting Started With Test-Driven Development
Changing Your Mindset: Getting Started With Test-Driven DevelopmentViget Labs
 
Dealing With Legacy PHP Applications
Dealing With Legacy PHP ApplicationsDealing With Legacy PHP Applications
Dealing With Legacy PHP ApplicationsViget Labs
 
Building and Working With Static Sites in Ruby on Rails
Building and Working With Static Sites in Ruby on RailsBuilding and Working With Static Sites in Ruby on Rails
Building and Working With Static Sites in Ruby on RailsViget Labs
 

More from Viget Labs (7)

9 Tips to Profitability: How Squidoo Did It
9 Tips to Profitability: How Squidoo Did It9 Tips to Profitability: How Squidoo Did It
9 Tips to Profitability: How Squidoo Did It
 
Advanced RESTful Rails
Advanced RESTful RailsAdvanced RESTful Rails
Advanced RESTful Rails
 
Hows Haml?
Hows Haml?Hows Haml?
Hows Haml?
 
Cleanliness is Next to Domain-Specificity
Cleanliness is Next to Domain-SpecificityCleanliness is Next to Domain-Specificity
Cleanliness is Next to Domain-Specificity
 
Changing Your Mindset: Getting Started With Test-Driven Development
Changing Your Mindset: Getting Started With Test-Driven DevelopmentChanging Your Mindset: Getting Started With Test-Driven Development
Changing Your Mindset: Getting Started With Test-Driven Development
 
Dealing With Legacy PHP Applications
Dealing With Legacy PHP ApplicationsDealing With Legacy PHP Applications
Dealing With Legacy PHP Applications
 
Building and Working With Static Sites in Ruby on Rails
Building and Working With Static Sites in Ruby on RailsBuilding and Working With Static Sites in Ruby on Rails
Building and Working With Static Sites in Ruby on Rails
 

Recently uploaded

B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptxB.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptxpriyanshujha201
 
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfDr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfAdmir Softic
 
Monte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMMonte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMRavindra Nath Shukla
 
0183760ssssssssssssssssssssssssssss00101011 (27).pdf
0183760ssssssssssssssssssssssssssss00101011 (27).pdf0183760ssssssssssssssssssssssssssss00101011 (27).pdf
0183760ssssssssssssssssssssssssssss00101011 (27).pdfRenandantas16
 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...Aggregage
 
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLMONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLSeo
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
M.C Lodges -- Guest House in Jhang.
M.C Lodges --  Guest House in Jhang.M.C Lodges --  Guest House in Jhang.
M.C Lodges -- Guest House in Jhang.Aaiza Hassan
 
Pharma Works Profile of Karan Communications
Pharma Works Profile of Karan CommunicationsPharma Works Profile of Karan Communications
Pharma Works Profile of Karan Communicationskarancommunications
 
7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...Paul Menig
 
Insurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageInsurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageMatteo Carbone
 
Monthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxMonthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxAndy Lambert
 
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...anilsa9823
 
It will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 MayIt will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 MayNZSG
 
Value Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and painsValue Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and painsP&CO
 
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...lizamodels9
 
Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Neil Kimberley
 
Grateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdfGrateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdfPaul Menig
 
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service AvailableDipal Arora
 
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesMysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesDipal Arora
 

Recently uploaded (20)

B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptxB.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
 
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfDr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
 
Monte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMMonte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSM
 
0183760ssssssssssssssssssssssssssss00101011 (27).pdf
0183760ssssssssssssssssssssssssssss00101011 (27).pdf0183760ssssssssssssssssssssssssssss00101011 (27).pdf
0183760ssssssssssssssssssssssssssss00101011 (27).pdf
 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
 
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLMONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
M.C Lodges -- Guest House in Jhang.
M.C Lodges --  Guest House in Jhang.M.C Lodges --  Guest House in Jhang.
M.C Lodges -- Guest House in Jhang.
 
Pharma Works Profile of Karan Communications
Pharma Works Profile of Karan CommunicationsPharma Works Profile of Karan Communications
Pharma Works Profile of Karan Communications
 
7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...
 
Insurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageInsurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usage
 
Monthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxMonthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptx
 
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
 
It will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 MayIt will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 May
 
Value Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and painsValue Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and pains
 
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
 
Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023
 
Grateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdfGrateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdf
 
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
 
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesMysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
 

Mockfight FlexMock vs Mocha

  • 1. Mockfight! FlexMock vs. Mocha Patrick Reagan patrick@viget.com Director, Application Development Viget Labs we build web business July 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 2. Mockfight! FlexMock vs. Mocha 2 What are Mocks? “Mock objects are simulated objects that mimic the behavior of real objects in controlled ways” - Wikipedia Viget Labs we build web business July 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 3. Mockfight! FlexMock vs. Mocha 3 When to Mock? Use mocks when you want to: • Control the behavior of internal method calls • Remove dependence on external systems • Improve test performance Viget Labs we build web business July 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 4. Mockfight! FlexMock vs. Mocha 4 Control Behavior What does this return? Need to maintain consistency between calls Viget Labs we build web business July 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 5. Mockfight! FlexMock vs. Mocha 5 Control Behavior How do we test? Magic happens here Stub the call to Die#rand (using Mocha) Viget Labs we build web business July 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 6. Mockfight! FlexMock vs. Mocha 6 Remove Dependencies Example: retrieve response data via HTTP To test this, we need to mock: • Call to URI#parse • Calls to Net::HTTP#new and Net::HTTP#head Viget Labs we build web business July 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 7. Mockfight! FlexMock vs. Mocha 7 Mockfight! Expanded example: • Create class method to check for resource • Handle errors and redirects • Iteratively develop functionality while testing • Examine the differences between libraries Viget Labs we build web business July 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 8. Mockfight! FlexMock vs. Mocha 8 Round 1 Test scenario when URI#parse raises exception Viget Labs we build web business July 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 9. Mockfight! FlexMock vs. Mocha 9 Round 1: Results FlexMock Mocha Viget Labs we build web business July 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 10. Mockfight! FlexMock vs. Mocha 10 Round 2 Check for a valid response Viget Labs we build web business July 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 11. Mockfight! FlexMock vs. Mocha 11 Round 2: Results FlexMock Mocha Viget Labs we build web business July 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 12. Mockfight! FlexMock vs. Mocha 12 Round 3 Check for response type instead of status code * Our previous tests for response status code are now invalid Viget Labs we build web business July 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 13. Mockfight! FlexMock vs. Mocha 13 Round 3: Results FlexMock Mocha Viget Labs we build web business July 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 14. Mockfight! FlexMock vs. Mocha 14 Round 4 Follow an HTTP redirect response Viget Labs we build web business July 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 15. Mockfight! FlexMock vs. Mocha 15 Round 4: Results FlexMock Viget Labs we build web business July 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 16. Mockfight! FlexMock vs. Mocha 16 Round 4: Results Mocha Viget Labs we build web business July 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 17. Mockfight! FlexMock vs. Mocha 17 Round 5 Handling maximum number of redirects Viget Labs we build web business July 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 18. Mockfight! FlexMock vs. Mocha 18 Round 5: Results FlexMock Viget Labs we build web business July 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 19. Mockfight! FlexMock vs. Mocha 19 Round 5: Results Mocha Viget Labs we build web business July 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 20. Mockfight! FlexMock vs. Mocha 20 Bonus Round Mocking ActiveRecord#find in controllers Viget Labs we build web business July 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 21. Mockfight! FlexMock vs. Mocha 21 Bonus Round: Results FlexMock Mocha Viget Labs we build web business July 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 22. Mockfight! FlexMock vs. Mocha 22 But Wait, There’s More Mocha has parameter matchers (in SVN) You can write code like this: Viget Labs we build web business July 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 23. Mockfight! FlexMock vs. Mocha 23 Conclusion • Newest versions of gems contain similar features • FlexMock can accept blocks for further mocking • Personal preference of syntax is the deciding factor Viget Labs we build web business July 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 24. Mockfight! FlexMock vs. Mocha 24 It’s a Tie! Ultimately, two great libraries - just pick one Viget Labs we build web business July 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 25. Mockfight! FlexMock vs. Mocha 25 Questions? ??? Viget Labs we build web business July 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 26. Mockfight! FlexMock vs. Mocha 26 Additional Information FlexMock (Jim Weirich) http://www.onestepback.org/software/flexmock Mocha (James Mead) http://mocha.rubyforge.org http://www.slideshare.net/viget Viget Labs we build web business July 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com