Skip to content

Conversation

@jperezish
Copy link

No description provided.

lib/api.rb Outdated
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.

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.

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