rspec-go-go-go 0.1.0 → 0.1.2
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/rspec/go_go_go/formatter.rb +30 -0
- data/lib/rspec/go_go_go/progress_counter.rb +30 -0
- data/lib/rspec/go_go_go/progress_framer.rb +28 -0
- data/lib/rspec/go_go_go/version.rb +7 -0
- data/lib/rspec/go_go_go.rb +4 -0
- data/progress_framer_spec.rb +58 -0
- data/rspec-go-go-go.gemspec +4 -3
- data/sig/rspec_go_go_go.rbs +1 -1
- metadata +8 -7
- data/lib/rspec_go_go_go/formatter.rb +0 -24
- data/lib/rspec_go_go_go/progress_counter.rb +0 -28
- data/lib/rspec_go_go_go/progress_framer.rb +0 -27
- data/lib/rspec_go_go_go/version.rb +0 -5
- data/lib/rspec_go_go_go.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd14bc3ee1a5a274215d2cbedfe0c3c3acf4109f55004588dfe04dd5a88ea94c
|
4
|
+
data.tar.gz: 22e02babcae990861b74a5d1efa144289f7520010704618ae11ad4b76d4b1ff7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f02f7f5532a0aeec18474d1834f71745d922e91dff26ab9e9a0ee6823656905c6e2fa5185aa206dbdeb83844651e6996d0fce496db4b69eeeb3cc6994a90815b
|
7
|
+
data.tar.gz: 33530428f9c4391fed679155b9d05d03b6b24819b2c5d22a366286838664353bb6f2b121cd69e95cc973e3b1cb3469791973ea8a06a8e405f831b394dcd7a585
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rspec/go_go_go/progress_counter"
|
4
|
+
require "rspec/go_go_go/progress_framer"
|
5
|
+
|
6
|
+
require "rspec/core"
|
7
|
+
require "rspec/core/formatters/base_text_formatter"
|
8
|
+
|
9
|
+
module RSpec
|
10
|
+
module GoGoGo
|
11
|
+
class Formatter < RSpec::Core::Formatters::BaseTextFormatter
|
12
|
+
RSpec::Core::Formatters.register self, :start, :example_passed, :example_failed
|
13
|
+
|
14
|
+
def start(notification)
|
15
|
+
super
|
16
|
+
@counter = ProgressCounter.new(notification.count)
|
17
|
+
end
|
18
|
+
|
19
|
+
def example_passed(_notification)
|
20
|
+
@counter.passed
|
21
|
+
@output << ProgressFramer.display(@counter)
|
22
|
+
end
|
23
|
+
|
24
|
+
def example_failed(_notification)
|
25
|
+
@counter.failed
|
26
|
+
@output << ProgressFramer.display(@counter)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RSpec
|
4
|
+
module GoGoGo
|
5
|
+
class ProgressCounter
|
6
|
+
def initialize(total)
|
7
|
+
@total = total
|
8
|
+
@passes = 0
|
9
|
+
@failures = 0
|
10
|
+
end
|
11
|
+
attr_reader :total, :passes, :failures
|
12
|
+
|
13
|
+
def passed
|
14
|
+
@passes += 1
|
15
|
+
end
|
16
|
+
|
17
|
+
def failed
|
18
|
+
@failures += 1
|
19
|
+
end
|
20
|
+
|
21
|
+
def checks
|
22
|
+
@passes + @failures
|
23
|
+
end
|
24
|
+
|
25
|
+
def rate
|
26
|
+
(checks.to_f / total).round(2)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module RSpec
|
3
|
+
module GoGoGo
|
4
|
+
module ProgressFramer
|
5
|
+
def display(counter)
|
6
|
+
"\r #{result(counter)} #{bar(counter)} #{rate(counter)}"
|
7
|
+
end
|
8
|
+
module_function :display
|
9
|
+
|
10
|
+
def bar(counter)
|
11
|
+
bar_len = counter.rate * 60.to_f
|
12
|
+
"|#{("=" * bar_len).ljust(60)}|"
|
13
|
+
end
|
14
|
+
module_function :bar
|
15
|
+
|
16
|
+
def result(counter)
|
17
|
+
"#{counter.checks} examples, #{counter.failures} failures"
|
18
|
+
end
|
19
|
+
module_function :result
|
20
|
+
|
21
|
+
def rate(counter)
|
22
|
+
percent = (counter.rate * 100.0).to_int
|
23
|
+
"#{format("%3s", percent)}%"
|
24
|
+
end
|
25
|
+
module_function :rate
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe RSpec::GoGoGo::ProgressFramer do
|
4
|
+
let(:counter) { RSpec::GoGoGo::ProgressCounter.new(3) }
|
5
|
+
|
6
|
+
context "when no progress" do
|
7
|
+
it "The number of executions and failures should be displayed." do
|
8
|
+
expect(described_class.result(counter)).to eq "0 examples, 0 failures"
|
9
|
+
end
|
10
|
+
|
11
|
+
it "progress rate must be 0" do
|
12
|
+
expect(described_class.rate(counter)).to eq " 0%"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "progress bar is not displayed." do
|
16
|
+
expect(described_class.bar(counter)).to eq "| |"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "when in progress" do
|
21
|
+
before do
|
22
|
+
counter.passed
|
23
|
+
counter.failed
|
24
|
+
end
|
25
|
+
|
26
|
+
it "The number of executions and failures should be displayed." do
|
27
|
+
expect(described_class.result(counter)).to eq "2 examples, 1 failures"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "progress rate must be 0" do
|
31
|
+
expect(described_class.rate(counter)).to eq " 67%"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "progress rate bar should be displayed.(until halfway point)" do
|
35
|
+
expect(described_class.bar(counter)).to eq "|======================================== |"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "when completed progress" do
|
40
|
+
before do
|
41
|
+
counter.passed
|
42
|
+
counter.failed
|
43
|
+
counter.failed
|
44
|
+
end
|
45
|
+
|
46
|
+
it "The number of executions and failures should be displayed." do
|
47
|
+
expect(described_class.result(counter)).to eq "3 examples, 2 failures"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "progress rate must be 0" do
|
51
|
+
expect(described_class.rate(counter)).to eq "100%"
|
52
|
+
end
|
53
|
+
|
54
|
+
it "progress rate bar should be displayed.(until the end)" do
|
55
|
+
expect(described_class.bar(counter)).to eq "|============================================================|"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/rspec-go-go-go.gemspec
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
|
2
|
+
lib = File.expand_path("lib", __dir__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "rspec/go_go_go/version"
|
4
5
|
|
5
6
|
Gem::Specification.new do |spec|
|
6
7
|
spec.name = "rspec-go-go-go"
|
7
|
-
spec.version =
|
8
|
+
spec.version = RSpec::GoGoGo::VERSION
|
8
9
|
spec.authors = ["fukurose"]
|
9
10
|
spec.email = ["tfukurose@gmail.com"]
|
10
11
|
|
data/sig/rspec_go_go_go.rbs
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-go-go-go
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fukurose
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This gem is a kind of rspec format. You can run rspec with progress bar.
|
14
14
|
email:
|
@@ -28,11 +28,12 @@ files:
|
|
28
28
|
- README.md
|
29
29
|
- Rakefile
|
30
30
|
- docker-compose.yml
|
31
|
-
- lib/
|
32
|
-
- lib/
|
33
|
-
- lib/
|
34
|
-
- lib/
|
35
|
-
- lib/
|
31
|
+
- lib/rspec/go_go_go.rb
|
32
|
+
- lib/rspec/go_go_go/formatter.rb
|
33
|
+
- lib/rspec/go_go_go/progress_counter.rb
|
34
|
+
- lib/rspec/go_go_go/progress_framer.rb
|
35
|
+
- lib/rspec/go_go_go/version.rb
|
36
|
+
- progress_framer_spec.rb
|
36
37
|
- rspec-go-go-go.gemspec
|
37
38
|
- sig/rspec_go_go_go.rbs
|
38
39
|
homepage: https://github.com/fukurose/rspec-go-go-go
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "rspec/core/formatters/base_text_formatter"
|
4
|
-
|
5
|
-
module RSpecGoGoGo
|
6
|
-
class Formater < RSpec::Core::Formatters::BaseTextFormatter
|
7
|
-
RSpec::Core::Formatters.register self, :start, :example_passed, :example_failed
|
8
|
-
|
9
|
-
def start(notification)
|
10
|
-
super
|
11
|
-
@counter = ProgressCounter.new(notification.count)
|
12
|
-
end
|
13
|
-
|
14
|
-
def example_passed(_notification)
|
15
|
-
@counter.passed
|
16
|
-
@output << ProgressFramer.display(@counter)
|
17
|
-
end
|
18
|
-
|
19
|
-
def example_failed(_notification)
|
20
|
-
@counter.failed
|
21
|
-
@output << ProgressFramer.display(@counter)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RSpecGoGoGo
|
4
|
-
class ProgressCounter
|
5
|
-
def initialize(total)
|
6
|
-
@total = total
|
7
|
-
@passes = 0
|
8
|
-
@failures = 0
|
9
|
-
end
|
10
|
-
attr_reader :total, :passes, :failures
|
11
|
-
|
12
|
-
def passed
|
13
|
-
@passes += 1
|
14
|
-
end
|
15
|
-
|
16
|
-
def failed
|
17
|
-
@failures += 1
|
18
|
-
end
|
19
|
-
|
20
|
-
def checks
|
21
|
-
@passes + @failures
|
22
|
-
end
|
23
|
-
|
24
|
-
def rate
|
25
|
-
(checks.to_f / total).round(2)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RSpecGoGoGo
|
4
|
-
module ProgressFramer
|
5
|
-
def display(counter)
|
6
|
-
"\r #{result(counter)} #{bar(counter)} #{rate(counter)}"
|
7
|
-
end
|
8
|
-
module_function :display
|
9
|
-
|
10
|
-
def bar(counter)
|
11
|
-
bar_len = counter.rate * 60.to_f
|
12
|
-
"|#{("=" * bar_len).ljust(60)}|"
|
13
|
-
end
|
14
|
-
module_function :bar
|
15
|
-
|
16
|
-
def result(counter)
|
17
|
-
"#{counter.checks} examples, #{counter.failures} failures"
|
18
|
-
end
|
19
|
-
module_function :result
|
20
|
-
|
21
|
-
def rate(counter)
|
22
|
-
percent = (counter.rate * 100.0).to_int
|
23
|
-
"#{format("%3s", percent)}%"
|
24
|
-
end
|
25
|
-
module_function :rate
|
26
|
-
end
|
27
|
-
end
|