Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
This talk is not about testing, nor is it really about mocking. However, analyzing a mock object library is a great way to showcase advanced Ruby topics. Have you ever wondered exactly how a mock object library does what it does? You can understand it! This talk uses a simplified mock object library as the basis for delving into topics such as metaprogramming and the Ruby object model. The goal is to increase the knowledge of these topics in the Ruby community. With this know--how, you will be better suited to build from and contribute to common Ruby tools that use them.
Date
Summarized using AI?
If this talk's summary was generated by AI, please check this box. A "Summarized using AI" badge will be displayed in the summary tab to indicate that the summary was generated using AI.
Show "Summarized using AI" badge on summary page
Summary
Markdown supported
In this video titled "Building a Mocking Library" presented by Andy Lindeman at Ancient City Ruby 2013, the speaker explores the construction of a simplified mocking library as a means to delve into advanced Ruby topics such as metaprogramming and the Ruby object model. The session emphasizes understanding the underlying mechanisms of mock object libraries, which often operate with a degree of abstraction that can obscure their workings from developers. Key points discussed include: - The motivation for creating a mocking library, as a tool used widely in the Ruby community but not commonly understood. - A brief overview of the syntax that will be used in the library, including methods such as `allow`, `expect`, `receive`, and `return`, which facilitate creating mock objects and stubs for testing. - The concept of a Domain Specific Language (DSL) that allows easy interaction with underlying methods and the importance of building a solid object base for the DSL. - An exploration of Ruby's method dispatching and the significance of understanding inheritance and singleton classes in Ruby when building the library. - The hands-on development of the library, which includes creating tests using MiniTest, defining methods within classes, and managing state within the mocking library to handle stubbing and unstubbing methods correctly. Throughout the talk, several coding demonstrations illustrate how to construct the library incrementally, along with practical examples like stubbing methods and creating expectations on method invocations. The session also addresses potential pitfalls, such as how to restore existing methods after stubbing and ensuring that the library behaves correctly even in edge cases affecting method visibility. Concluding remarks emphasize that constructing such a mocking library not only deepens understanding of Ruby but also equips developers with skills applicable to broader coding practices, especially in testing scenarios. Lindeman encourages attendees to experiment with the code and find ways to enhance functionality further, promising that features like `expect` and `allow` could potentially be integrated into future versions of RSpec. Overall, the video serves as both a technical tutorial and an insightful exploration into Ruby's capabilities, inspiring developers to deepen their knowledge of the Ruby language and its testing frameworks.
Suggest modifications
Cancel