• Email
  • Like
  • Save
  • Private Content
  • Embed
 

Changing Your Mindset: Getting Started With Test-Driven Development

by 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

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

Cancel

2 Embeds 21

http://wiki.lonestarrubyconf.com 13
http://www.slideshare.net 8

Statistics

Likes
4
Downloads
182
Comments
1
Embed Views
21
Views on SlideShare
7,367
Total Views
7,388

11 of 1 previous next

  • viget Viget Labs at Viget Labs In order to keep the code to a minimum, I just discussed how I moved the File.read call (from slide 13) into a google_content() method. This was my implementation (I had saved the output to a file on disk):

    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
    Are you sure you want to
Post Comment
Edit your comment

Changing Your Mindset: Getting Started With Test-Driven Development Changing Your Mindset: Getting Started With Test-Driven Development Presentation Transcript