-
-
Save rubiii/1036525 to your computer and use it in GitHub Desktop.
A fortune rspec formatter. Make all your specs pass to get a new fortune!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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