public
Created — forked from thilko/FortuneFormatter.rb

A fortune rspec formatter. Make all your specs pass to get a new fortune!

  • Download Gist
FortuneFormatter.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
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
README.textile
Textile

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 :-)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.