Skip to content

Instantly share code, notes, and snippets.

@curiositycasualty
Forked from spicycode/README.md
Created October 13, 2014 02:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save curiositycasualty/8662c8a4daecd84572fb to your computer and use it in GitHub Desktop.
Save curiositycasualty/8662c8a4daecd84572fb to your computer and use it in GitHub Desktop.

YELLY!!!!! THE YELLINGIST FORMATTER EVER!!!!!

Yelly likes to yell. To make the magic happen for simple cases just invoke him ala:

bundle exec rspec --require=yelly_the_yellingist_formatter.rb --format=YellyTheYellingistFormatter spec/models/your_file_here_spec.rb

In closing, >:O

Updated to Rspec 3.0's formatter interface.

require 'rspec/core/formatters/documentation_formatter'
class YellyTheYellingistFormatter < RSpec::Core::Formatters::DocumentationFormatter
RSpec::Core::Formatters.register self, :example_passed,
:example_pending,
:example_failed
def initialize(*args)
super
end
def example_passed(notification)
dabble_in_that_which_should_not_be_dabbled('yes!', notification)
super
shout!('yes!', notification)
end
def example_failed(notification)
dabble_in_that_which_should_not_be_dabbled('no!', notification)
super
shout!('no!', notification)
end
def example_pending(notification)
dabble_in_that_which_should_not_be_dabbled('meh', notification)
super
shout!('meh', notification)
end
private
def dabble_in_that_which_should_not_be_dabbled(say_what_now, notification)
notification.example.metadata[:description] = "#{say_what_now.upcase} - #{notification.example.metadata[:description]}"
end
def shout!(say_what_now, notification)
return unless you_got_the_pipes?
system("say", say_what_now)
end
def you_got_the_pipes?
@pipes_present ||= system('which say > /dev/null')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment