rspeji 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bin/rspeji +25 -0
- data/lib/emoji.rb +44 -0
- data/lib/rspeji.rb +86 -0
- metadata +47 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 9c21114c1ffddd2157e8af1be8f11b90078cde93
|
|
4
|
+
data.tar.gz: a131f862e8a0b85507bd35985e2adac44ee4c62f
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 90d6df1336c9b25e161cc973b1e9aee7ce20e52efced7314e8c39ae658836182a80517a3ba531439d73ff81c897d0f2f32614637624b7bbcf89af05a693297a0
|
|
7
|
+
data.tar.gz: 4c93114a7fcbd4ad9a12783beba5e20725c45fd9bb501dcd17e52bfe769523e7a0b638613e01c96e9fb4bb8b1cb46e134d8a8649d80967c27101d625563699c9
|
data/bin/rspeji
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require_relative '../lib/emoji.rb'
|
|
4
|
+
|
|
5
|
+
@delimeter_length = 20
|
|
6
|
+
|
|
7
|
+
def title_line(title)
|
|
8
|
+
padding = @delimeter_length - 3 - title.length
|
|
9
|
+
"== #{title} " + ("=" * padding) + "\n"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def end_line
|
|
13
|
+
"=" * @delimeter_length
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
table = Emoji.list.map do |emoji, value|
|
|
17
|
+
title_line(emoji) +
|
|
18
|
+
"passed: #{value[0]}\n" +
|
|
19
|
+
"pending: #{value[1]}\n" +
|
|
20
|
+
"failed: #{value[2]}"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
table << end_line
|
|
24
|
+
|
|
25
|
+
puts table.join("\n")
|
data/lib/emoji.rb
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# Emoji class
|
|
3
|
+
class Emoji
|
|
4
|
+
attr_reader :selected_set
|
|
5
|
+
# Constant tih all the emoji sets
|
|
6
|
+
LIST = {
|
|
7
|
+
smiley: ["😃 ", "😰 ", "😡 "],
|
|
8
|
+
heart: ["💚 ", "💙 ", "💔 "],
|
|
9
|
+
smiley2: ["😍 ", "😩 ", "😭 🔫 "],
|
|
10
|
+
hand: ["👍 ", "👋 ", "👎 "],
|
|
11
|
+
moon: ["🌝 ", "🌓 ", "🌚 "],
|
|
12
|
+
buildings: ["🏩 ", "🏫 ", "🏥 "],
|
|
13
|
+
woman: ["🙆 ", "🙋 ", "🙍 "],
|
|
14
|
+
stock: ["📈 ", "📊 ", "📉 "],
|
|
15
|
+
monkey: ["🙈 ", "🙉 ", "🙊 "],
|
|
16
|
+
cats: ["😸 ", "🙀 ", "😾 "],
|
|
17
|
+
smell: ["🌺 ", "👃 ", "💩 "],
|
|
18
|
+
fruit: ["🍏 ", "🍋 ", "🍎 "],
|
|
19
|
+
speach: ["💭 ", "💬 ", "🗯 "]
|
|
20
|
+
}.freeze
|
|
21
|
+
def initialize(emoji_spec)
|
|
22
|
+
@selected_set = if !emoji_spec.nil? && LIST.key?(emoji_spec.to_sym)
|
|
23
|
+
emoji_spec.to_sym
|
|
24
|
+
else
|
|
25
|
+
LIST.keys.sample
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def passed
|
|
30
|
+
LIST[@selected_set][0]
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def pending
|
|
34
|
+
LIST[@selected_set][1]
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def failed
|
|
38
|
+
LIST[@selected_set][2]
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def self.list
|
|
42
|
+
LIST
|
|
43
|
+
end
|
|
44
|
+
end
|
data/lib/rspeji.rb
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
require "emoji"
|
|
2
|
+
class Rspeji
|
|
3
|
+
RSpec::Core::Formatters.register self,
|
|
4
|
+
:dump_pending,
|
|
5
|
+
:dump_failures,
|
|
6
|
+
:close,
|
|
7
|
+
:dump_summary,
|
|
8
|
+
:example_passed,
|
|
9
|
+
:example_failed,
|
|
10
|
+
:example_pending
|
|
11
|
+
|
|
12
|
+
def initialize(output)
|
|
13
|
+
@emoji = Emoji.new(ENV["EMOJI_SPEC"])
|
|
14
|
+
@output = output
|
|
15
|
+
@output << "Using Rspeji with #{@emoji.selected_set} and:\n"
|
|
16
|
+
@output << "passed: #{@emoji.passed} / pending: #{@emoji.pending} / failed: #{@emoji.failed}\n"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def example_passed(notification)
|
|
20
|
+
@output << @emoji.passed
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def example_pending(notification)
|
|
24
|
+
@output << @emoji.pending
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def example_failed(notification)
|
|
28
|
+
@output << @emoji.failed
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def dump_summary(notification)
|
|
32
|
+
@output << "\n\nFinished in #{RSpec::Core::Formatters::Helpers.format_duration(notification.duration)}."
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def close(notification)
|
|
36
|
+
@output << "\n"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def dump_pending(notification)
|
|
40
|
+
if notification.pending_examples.length > 0
|
|
41
|
+
@output << "\n\n#{RSpec::Core::Formatters::ConsoleCodes.wrap("PENDING:", :pending)}\n\t"
|
|
42
|
+
@output << notification.pending_examples.map { |example| example.full_description + " - " + example.location }.join("\n\t")
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def dump_failures(notification)
|
|
47
|
+
if notification.failed_examples.length > 0
|
|
48
|
+
@output << "\n#{RSpec::Core::Formatters::ConsoleCodes.wrap("FAILING:", :failure)}\n\t"
|
|
49
|
+
@output << failed_examples_output(notification)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
55
|
+
# Loops through all of the failed examples and rebuilds the exception message
|
|
56
|
+
def failed_examples_output(notification)
|
|
57
|
+
failed_examples_output = notification.failed_examples.map do |example|
|
|
58
|
+
failed_example_output example
|
|
59
|
+
end
|
|
60
|
+
build_examples_output(failed_examples_output)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Joins all exception messages
|
|
64
|
+
def build_examples_output(output)
|
|
65
|
+
output.join("\n\n\t")
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Extracts the full_description, location and formats
|
|
69
|
+
# the message of each example exception
|
|
70
|
+
def failed_example_output(example)
|
|
71
|
+
full_description = example.full_description
|
|
72
|
+
location = example.location
|
|
73
|
+
formatted_message = strip_message_from_whitespace(example.execution_result.exception.message)
|
|
74
|
+
|
|
75
|
+
"#{full_description} - #{location} \n #{formatted_message}"
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Removes whitespace from each of the exception message lines and reformats it
|
|
79
|
+
def strip_message_from_whitespace(msg)
|
|
80
|
+
msg.split("\n").map(&:strip).join("\n#{add_spaces(10)}")
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def add_spaces(n)
|
|
84
|
+
" " * n
|
|
85
|
+
end
|
|
86
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: rspeji
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Paolo Fabbri
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2017-09-23 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Let's put some emoji in your test's
|
|
14
|
+
email: info@internetblacksmith.co.uk
|
|
15
|
+
executables:
|
|
16
|
+
- rspeji
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- bin/rspeji
|
|
21
|
+
- lib/emoji.rb
|
|
22
|
+
- lib/rspeji.rb
|
|
23
|
+
homepage: http://internetblacksmith.co.uk/
|
|
24
|
+
licenses:
|
|
25
|
+
- MIT
|
|
26
|
+
metadata: {}
|
|
27
|
+
post_install_message:
|
|
28
|
+
rdoc_options: []
|
|
29
|
+
require_paths:
|
|
30
|
+
- lib
|
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
32
|
+
requirements:
|
|
33
|
+
- - ">="
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: '0'
|
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
requirements: []
|
|
42
|
+
rubyforge_project:
|
|
43
|
+
rubygems_version: 2.5.1
|
|
44
|
+
signing_key:
|
|
45
|
+
specification_version: 4
|
|
46
|
+
summary: Emoji!!
|
|
47
|
+
test_files: []
|