Skip to content
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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

jperezish
Copy link

No description provided.

year: struct.year,
score: struct.ratings["critics_score"]
)
if struct.respond_to?(:title)
Copy link
Member

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

@jperezish
Copy link
Author

@jwo here's my Tiger level.

clerk.movie_score_average.should eq(54.5)
end

$stdout = StringIO.new
Copy link
Member

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.

Copy link
Member

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"

@jwo
Copy link
Member

jwo commented Feb 6, 2014

Code looks excellent, btw. great submission

@jperezish
Copy link
Author

@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)
Copy link
Member

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)

@jwo
Copy link
Member

jwo commented Feb 11, 2014

Most excellent job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants