-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Panda - fix search results to not throw an error if movie not found #25
base: master
Are you sure you want to change the base?
Conversation
year: struct.year, | ||
score: struct.ratings["critics_score"] | ||
) | ||
if struct.respond_to?(:title) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting use of respond_to here
@jwo here's my Tiger level. |
clerk.movie_score_average.should eq(54.5) | ||
end | ||
|
||
$stdout = StringIO.new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good stuff on $stdout.... usually, when you re-assign stdout, you want to only do it temporarily, so you can do your thing, check your thing, and reset your thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use this technique on http://thinkingdigitally.com/archive/capturing-output-from-puts-in-ruby/
require 'stringio'
module Kernel
def capture_stdout
out = StringIO.new
$stdout = out
yield
return out
ensure
$stdout = STDOUT
end
end
results = capture_stdout do
puts "hi!"
end
results.string
=> "hi!\n"
Only real tricky part is the "\n".... if you hate that, you could change to
results = capture_stdout do
print "hi"
end
results.string
=> "hi"
Code looks excellent, btw. great submission |
@jwo added the Eagle level. |
clerk.search_by_title("fargo") | ||
clerk.search_by_title("spaceballs") | ||
clerk.analyze_taste | ||
clerk.taste_measurement.should eq(4.444444444444445) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to use the "is near" when dealing with stuff like this.
clerk.tast_measurement.should be_within(0.01).of(4.44)
Most excellent job! |
…age to use local variable and map inject
No description provided.