Skip to content

Instantly share code, notes, and snippets.

@rubiii
Forked from thilko/FortuneFormatter.rb
Created June 20, 2011 20:40
Show Gist options
  • Select an option

  • Save rubiii/1036525 to your computer and use it in GitHub Desktop.

Select an option

Save rubiii/1036525 to your computer and use it in GitHub Desktop.

Revisions

  1. rubiii revised this gist Jun 20, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.textile
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@ Get your fortune now! Let all your specs pass and the next fortune will appear.

    h1. Usage

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

    h1. Notes

  2. blackhacker revised this gist Jun 20, 2011. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions README.textile
    Original file line number Diff line number Diff line change
    @@ -5,9 +5,7 @@ Get your fortune now! Let all your specs pass and the next fortune will appear.

    h1. Usage

    {noformat}
    rspec -r ./fortune_formatter.rb -f FortuneFormatter
    {noformat}
    bc. $ rspec -r ./fortune_formatter.rb -f FortuneFormatter

    h1. Notes

  3. blackhacker revised this gist Jun 20, 2011. 1 changed file with 11 additions and 0 deletions.
    11 changes: 11 additions & 0 deletions README.textile
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,14 @@
    h1. FortuneFormatter

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


    h1. Usage

    {noformat}
    rspec -r ./fortune_formatter.rb -f FortuneFormatter
    {noformat}

    h1. Notes

    * Doesn´t work very well with webmock :-)
  4. blackhacker revised this gist Jun 20, 2011. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions README.textile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    h1. FortuneFormatter
    Get your fortune now! Let all your specs pass and the next fortune will appear.

  5. Thilko Richter revised this gist Jun 20, 2011. No changes.
  6. Thilko Richter created this gist Jun 20, 2011.
    20 changes: 20 additions & 0 deletions FortuneFormatter.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,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