public
Last active

emoji_spec is a microgem to put emoji in your rspec output.

  • Download Gist
README.md
Markdown

Emoji Spec

results Tired of the same, dull rspec output? liven it up with some emoji!

Below are the sets presently available, and their corresponding id. if you don't set an ID, one will be randomly chosen every run. Emoji icons may not render in certain terminals.

(pass, fail, pending)

emoji

Installation

put it in your gemfile, under the test group.

  gem 'emoji_spec', :git => "https://gist.github.com/6112257.git"

Usage

Trying it out

Formatter

pass the formatter option in when you run the rspec command, like so

$ rspec spec --format EmojiFormatter

Specify Emoji group

to pick a specific set, set the enviroment variable EMOJI_SPEC like so

$ EMOJI_SPEC=1 rspec spec/

you can also do

$ export EMOJI_SPEC=1 

to set it for this terminal session

Setting for good

Formatter

create or edit .rspec in your project directory and add --format EmojiFormatter to it.

Specify Emoji group

A few ways to do this, the easiest is to edit your ~/.bash_profile and add export EMOJI_SPEC=1

emoji_formatter.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
# encoding: UTF-8
 
require 'rspec/core/formatters/base_text_formatter'
class EmojiFormatter < RSpec::Core::Formatters::BaseTextFormatter
EMOJILIB = [
["😃","😡","😰"],
["💚","💔","💙"],
["😍","😭 🔫","😩"],
["👍","👎","👋"],
["🌝","🌚","🌓"],
["🏩","🏥","🏫"],
["🍰","💩","🎃"],
["🆗","⛔","❔"],
["🙆","🙍","🙋"],
["📈","📉","📊"],
["⚪","🔴","🔵"],
["🙈","🙊","🙉"],
["🍺"," F-💣","🔮"],
["😸", "😾", "🙀"],
["🌺","💩","👃"],
["🐼","🐴","🐘"],
["🍏","🍎","🍋"]]
 
# pass in EMOJI_SPEC at command line to set specific collection; random otherwise.
length= EMOJILIB.size - 1
val = (!ENV["EMOJI_SPEC"].nil? && ENV["EMOJI_SPEC"].to_i - 1) || [*0..length].sample
EMOJI = EMOJILIB[val]
puts "Using emoji set: #{(val + 1).to_s}"
puts "Pass: #{EMOJI[0]} / Fail: #{EMOJI[1]} / Pending: #{EMOJI[2]}"
def example_passed(example)
super(example)
output.print(self.class::EMOJI[0] + " ")
end
def example_pending(example)
super(example)
output.print(self.class::EMOJI[2] + " ")
end
def example_failed(example)
super(example)
output.print(self.class::EMOJI[1] + " ")
end
 
end
emoji_spec.gemspec
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13
Gem::Specification.new do |s|
s.name = 'emoji_spec'
s.version = '0.1'
s.platform = Gem::Platform::RUBY
s.author = 'Russell Jennings'
s.email = 'russell@novafabrica.com'
s.summary = 'Emoji in your rspec output'
s.description = 'Replaces the boring textual representations of spec results with EMOJI.'
s.files = ['emoji_formatter.rb']
s.require_path = '.'
s.add_development_dependency('rspec', ["~> 2.0"])
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.