rspec-kungfuhamster 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/rspec_kung_fu_hamster.rb +40 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecb64e5c8de36ef5855f65f928d1a34b6a66159e
|
4
|
+
data.tar.gz: 55588280b3b71c1009d421e4fb39f3562333a887
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a718ff778697d3f140735a0c5fe130538378ce281bfc1cb94ee5c18d2f6278057242c1f2c35a61423b35bf8a84082c9eaefb2e8e4cf7c31ee3878ffa3e47d2b
|
7
|
+
data.tar.gz: c3e31df35c776c24a4f7e0bd08c7f671ddd4f1bc2c46843f8c81c992c487bb4bc99a15f62d45453855a0214596806cf663217e41d0d7f63d8b9dca3d8d276894
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'rspec'
|
2
|
-
|
2
|
+
require 'rspec/core/formatters/base_text_formatter'
|
3
3
|
|
4
4
|
rspec_bin = $0.split('/').last
|
5
5
|
|
@@ -8,22 +8,55 @@ class RspecKungFuHamster < RSpec::Core::Formatters::BaseTextFormatter
|
|
8
8
|
# :start,
|
9
9
|
# :example_start
|
10
10
|
# :message,
|
11
|
-
:example_passed
|
12
|
-
|
13
|
-
|
11
|
+
:example_passed,
|
12
|
+
:example_pending,
|
13
|
+
:example_failed
|
14
14
|
# :dump_failures
|
15
15
|
|
16
16
|
def initialize(output)
|
17
17
|
@index = 0
|
18
|
+
@example_passed = 0
|
19
|
+
@example_pending = 0
|
20
|
+
@example_failed = 0
|
18
21
|
super(output)
|
19
22
|
end
|
20
23
|
|
24
|
+
def color_positions(length)
|
25
|
+
total = @example_passed + @example_pending + @example_failed
|
26
|
+
passed_percent = @example_passed * length / total
|
27
|
+
pending_percent = @example_pending * length / total
|
28
|
+
|
29
|
+
[passed_percent, passed_percent + pending_percent, length]
|
30
|
+
end
|
31
|
+
|
32
|
+
GREEN = "\e[32m"
|
33
|
+
YELLOW = "\e[33m"
|
34
|
+
RED = "\e[31m"
|
35
|
+
RESET = "\e[0m"
|
36
|
+
|
37
|
+
def colorize(string)
|
38
|
+
green, yellow, red = color_positions(string.length)
|
39
|
+
GREEN + string[0...green] + YELLOW + string[green...yellow] + RED + string[yellow...red] + RESET
|
40
|
+
end
|
41
|
+
|
42
|
+
def display(strings)
|
43
|
+
colorize(strings.join("\n"))
|
44
|
+
end
|
45
|
+
|
46
|
+
def output_hamster
|
47
|
+
output.puts "\e[2J\e[;H" + display(hamster_and_next)
|
48
|
+
end
|
21
49
|
def example_passed(notification)
|
22
|
-
|
50
|
+
@example_passed += 1
|
51
|
+
output_hamster
|
52
|
+
end
|
53
|
+
def example_pending(notification)
|
54
|
+
@example_pending += 1
|
55
|
+
output_hamster
|
23
56
|
end
|
24
57
|
def example_failed(notification)
|
25
|
-
|
26
|
-
|
58
|
+
@example_failed += 1
|
59
|
+
output_hamster
|
27
60
|
end
|
28
61
|
|
29
62
|
def hamster_and_next
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-kungfuhamster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Powell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|