Viget Labs
commented on
Hows Haml?It didn’t come across in the slides, but though I mentioned performance as compared to both ERB and Erubis I didn’t stress it as something a developer should care about. If you’re looking to get more performance out of your application, you should really be looking at the database and other areas before worrying about your rendering engine.2 years ago
Viget Labs
commented on
Changing Your Mindset: Getting Started With Test-Driven DevelopmentIn 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.3 years ago
Comments