rspec-go-go-go 0.1.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc7ad2b0c5760e66d50974741dcf4e124b3bba29956f872e62f46af43d01ca15
4
- data.tar.gz: 10694247f574fc4237d57eb4bf0817e46323293ad2caf0c1a9349d65505e5220
3
+ metadata.gz: dd14bc3ee1a5a274215d2cbedfe0c3c3acf4109f55004588dfe04dd5a88ea94c
4
+ data.tar.gz: 22e02babcae990861b74a5d1efa144289f7520010704618ae11ad4b76d4b1ff7
5
5
  SHA512:
6
- metadata.gz: 3c1ff2858be5789b6b4e4add254b164e01ebaff6275bef897464de73f18b9d7f140866829d9eedfc26ced6e205274e0bf0198a7c8570862e022f01558355c842
7
- data.tar.gz: 1bd820b8943f67a21d7b1de0c615e7fdd3728351a80a1e22e1a2f0aef6813a39b55129cf8dcaa562ed10c920502e0f9c283694047ddf4e5cd0a1f26aa0da56b5
6
+ metadata.gz: f02f7f5532a0aeec18474d1834f71745d922e91dff26ab9e9a0ee6823656905c6e2fa5185aa206dbdeb83844651e6996d0fce496db4b69eeeb3cc6994a90815b
7
+ data.tar.gz: 33530428f9c4391fed679155b9d05d03b6b24819b2c5d22a366286838664353bb6f2b121cd69e95cc973e3b1cb3469791973ea8a06a8e405f831b394dcd7a585
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-go-go-go (0.1.1)
4
+ rspec-go-go-go (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RSpec
4
+ module GoGoGo
5
+ VERSION = "0.1.2"
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rspec/go_go_go/version"
4
+ require "rspec/go_go_go/formatter"
@@ -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
@@ -1,10 +1,11 @@
1
1
  # frozen_string_literal: true
2
-
3
- require_relative "lib/rspec_go_go_go/version"
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 = RSpecGoGoGo::VERSION
8
+ spec.version = RSpec::GoGoGo::VERSION
8
9
  spec.authors = ["fukurose"]
9
10
  spec.email = ["tfukurose@gmail.com"]
10
11
 
@@ -1,4 +1,4 @@
1
- module RSpecGoGoGo
1
+ module RSpec::GoGoGo
2
2
  VERSION: String
3
3
  # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
4
  end
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.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-06 00:00:00.000000000 Z
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,10 +28,12 @@ files:
28
28
  - README.md
29
29
  - Rakefile
30
30
  - docker-compose.yml
31
- - lib/rspec_go_go_go.rb
32
- - lib/rspec_go_go_go/progress_counter.rb
33
- - lib/rspec_go_go_go/progress_framer.rb
34
- - lib/rspec_go_go_go/version.rb
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
35
37
  - rspec-go-go-go.gemspec
36
38
  - sig/rspec_go_go_go.rbs
37
39
  homepage: https://github.com/fukurose/rspec-go-go-go
@@ -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
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RSpecGoGoGo
4
- VERSION = "0.1.1"
5
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rspec_go_go_go/version"
4
- require "rspec_go_go_go/progress_counter"
5
- require "rspec_go_go_go/progress_framer"
6
-
7
- require "rspec/core"
8
- require "rspec/core/formatters/base_text_formatter"
9
-
10
- module RSpecGoGoGo
11
- class Formater < 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