Skip to content

@rubiii /FortuneFormatter.rb forked from thilko/FortuneFormatter.rb
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A fortune rspec formatter. Make all your specs pass to get a new fortune!

FortuneFormatter

Get your fortune now! Let all your specs pass and the next fortune will appear.

Usage

$ rspec -r ./fortune_formatter.rb -f FortuneFormatter

Notes

  • Doesn´t work very well with webmock :-)
require 'rspec/core/formatters/progress_formatter'
require "net/http"
class FortuneFormatter < RSpec::Core::Formatters::ProgressFormatter
def stop
super
print_fortune if all_passed?
end
def all_passed?
failure_count == 0 && pending_count == 0
end
def print_fortune
response = Net::HTTP.start("brenocon.com") { |connect| connect.get "/fortune.cgi" }
message "\n<====FORTUNE=============>"
message response.body.scan(/<PRE>.(.*).?<\/PRE>/im).flatten.first.chomp
message "<========================>"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.