Changing Your Mindset: Getting Started With Test-Driven Development
by Viget Labs on Sep 06, 2007
- 7,388 views
Patrick Reagan introduces the concept of Test-Driven development with code examples and gives some lessons learned from experience in the field.
Patrick Reagan introduces the concept of Test-Driven development with code examples and gives some lessons learned from experience in the field.
Accessibility
Categories
Upload Details
Uploaded via SlideShare as Adobe PDF
Usage Rights
© All Rights Reserved
Statistics
- Likes
- 4
- Downloads
- 182
- Comments
- 1
- Embed Views
- Views on SlideShare
- 7,367
- Total Views
- 7,388
def google_content
File.read(File.join(File.dirname(__FILE__), 'data/google_search.html'))
end
I like the refactoring in your example - here's a change that would combine the original concept with your changes (using Mocha to mock):
def google_response
content = File.read(File.join(File.dirname(__FILE__), 'data/google_search.html'))
response = Net::HTTPSuccess.new('1.2', '200', 'OK')
response.expects(:body).returns(content)
response
end
I changed the name to reflect the changed behavior - the only improvement I can see would be to mimic different responses (e.g. server error, etc...) either as part of this method or other methods.
Thanks for the feedback.
5 years ago