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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 83e445d6b6f36abbdc071fa90fc752bbe001d090
4
- data.tar.gz: a6e0f962912f05dfa28af4069871ba5e004f9b7d
3
+ metadata.gz: ecb64e5c8de36ef5855f65f928d1a34b6a66159e
4
+ data.tar.gz: 55588280b3b71c1009d421e4fb39f3562333a887
5
5
  SHA512:
6
- metadata.gz: f768b438b5f6d2032b2d6006547755c6474a5960b373af949a42789e0ec1ab61cb287634ec506ccfdfd05da3f2b85178afa6e1217cf6ef7959013c4a48d0b80e
7
- data.tar.gz: 9be05a6034129734b493b0e5cb302abbb3be9f5cad59ed97e06d863c37bb4da826223d925b82fa673dd3a8608a57f2f48df13f18e2678b9b2bdaccf6c4f98404
6
+ metadata.gz: 9a718ff778697d3f140735a0c5fe130538378ce281bfc1cb94ee5c18d2f6278057242c1f2c35a61423b35bf8a84082c9eaefb2e8e4cf7c31ee3878ffa3e47d2b
7
+ data.tar.gz: c3e31df35c776c24a4f7e0bd08c7f671ddd4f1bc2c46843f8c81c992c487bb4bc99a15f62d45453855a0214596806cf663217e41d0d7f63d8b9dca3d8d276894
data/README.md CHANGED
@@ -2,3 +2,11 @@ rspec-kungfuhamster
2
2
  ======================
3
3
 
4
4
  Animated kung fu hamster formatter
5
+
6
+ # Installation
7
+
8
+ Add this to you Gemfile (in the test group) and run `bundle install`:
9
+
10
+ ``` ruby
11
+ gem 'rspec-kungfuhamster'
12
+ ```
@@ -1,5 +1,5 @@
1
1
  require 'rspec'
2
- require 'rspec/core/formatters/base_text_formatter'
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
- # :example_pending,
13
- # :example_failed,
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
- output.puts "\e[2J\e[;H" << hamster_and_next.join("\n")
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
- output.puts "\e[2J\e[;H" << hamster_and_next.join("\n")
26
- sleep 0.1
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.0
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-10-31 00:00:00.000000000 Z
11
+ date: 2014-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec