rspec-go-go-go 0.1.3 → 1.0.0

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: 5bcee5cca4a0494e03982e14f604be2481981e65589dbc991285ad173c6f44d7
4
- data.tar.gz: f6bc0fd95992d2f90d95c8d89896a0f6f8ebd329b5cfbf96757bc78f1fc6ff50
3
+ metadata.gz: 51c6e016a3ba088692bbe41dabe3b03001f0a850aeb2054888519cb837eae037
4
+ data.tar.gz: b531e74f9c09cda0cf8134f203e62c62a0d12df9fd646dd7184c6638378dd872
5
5
  SHA512:
6
- metadata.gz: 687bb2301164578171bab2dbd176c90d2aed5f97faa68e211b69ef5f5958de930420f8c5f513b53890211667c4fd9e88bd8294e73a9276fc828ab79073d9dad9
7
- data.tar.gz: 356d35aa763c40d3ca850b85eb42f8f7f90cf542bfe191c9b1c5f9cf013b54bab2621baddfc0edd2289ef74a71bf8b252fa3b6594237cdd26604f5c6aed62d7f
6
+ metadata.gz: a5d34dcfc52ae516eb5f92a90eaed4b93de3a90cda6501853f8d004f1c17e5430424e0c8b29b319f0e283e98d744a2ac2d4a7dc8fd6872716942a8cf1794c962
7
+ data.tar.gz: 5a8df829ea8ea34cd0c4fb2daa56e0eb3c57dd20962b6651cb03e07688f206e109ec013246709e77731c9a6f37cb8a97f12df7a7b9c5fbe6a0372283d0f5ba5b
data/.rubocop.yml CHANGED
@@ -2,6 +2,7 @@ require: rubocop-rspec
2
2
 
3
3
  AllCops:
4
4
  NewCops: enable
5
+ SuggestExtensions: false
5
6
 
6
7
  Style/StringLiterals:
7
8
  Enabled: true
@@ -19,4 +20,10 @@ Style/Documentation:
19
20
 
20
21
  RSpec/FilePath:
21
22
  Enabled: false
23
+
24
+ Style/TrailingCommaInArrayLiteral:
25
+ EnforcedStyleForMultiline: comma
26
+
27
+ Style/TrailingCommaInHashLiteral:
28
+ EnforcedStyleForMultiline: comma
22
29
 
data/Gemfile CHANGED
@@ -11,4 +11,4 @@ gem "rspec", "~> 3.0"
11
11
 
12
12
  gem "rubocop", "~> 1.21"
13
13
 
14
- gem 'rubocop-rspec', "~> 2.13"
14
+ gem "rubocop-rspec", "~> 2.13"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-go-go-go (0.1.3)
4
+ rspec-go-go-go (1.0.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -48,6 +48,7 @@ GEM
48
48
 
49
49
  PLATFORMS
50
50
  aarch64-linux
51
+ x86_64-linux
51
52
 
52
53
  DEPENDENCIES
53
54
  rake (~> 13.0)
data/README.md CHANGED
@@ -1,15 +1,14 @@
1
1
  # RSpecGoGoGo
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rspec_go_go_go`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Run RSpec with progress bar.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
6
5
 
7
6
  ## Installation
8
7
 
9
8
  Add this line to your application's Gemfile:
10
9
 
11
10
  ```ruby
12
- gem 'rspec_go_go_go'
11
+ gem 'rspec-go-go-go'
13
12
  ```
14
13
 
15
14
  And then execute:
@@ -18,26 +17,33 @@ And then execute:
18
17
 
19
18
  Or install it yourself as:
20
19
 
21
- $ gem install rspec_go_go_go
20
+ $ gem install rspec-go-go-go
22
21
 
23
22
  ## Usage
24
23
 
25
- TODO: Write usage instructions here
26
-
27
- ## Development
24
+ ```
25
+ rspec --format RSpec::GoGoGo::Formatter
26
+ ```
28
27
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+ or write .rspec
30
29
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+ ```
31
+ --format RSpec::GoGoGo::Formatter
32
+ ```
32
33
 
33
34
  ## Contributing
34
35
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rspec_go_go_go. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/rspec_go_go_go/blob/master/CODE_OF_CONDUCT.md).
36
+ Bug reports and pull requests are welcome on GitHub at https://github.com/fukurose/rspec-go-go-go.
36
37
 
37
- ## License
38
+ After checking out the repository, you need to install dependencies:
39
+ ```
40
+ gem install bundler -v 2.3.7
41
+ bundle install
42
+ ```
38
43
 
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
44
+ To install this gem on your local machine, run `bundle exec rake install`.
45
+ Please check your contributions with RuboCop by running `bundle exec rubocop`.
40
46
 
41
- ## Code of Conduct
47
+ ## License
42
48
 
43
- Everyone interacting in the RSpecGoGoGo project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/rspec_go_go_go/blob/master/CODE_OF_CONDUCT.md).
49
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -13,16 +13,20 @@ module RSpec
13
13
 
14
14
  def start(notification)
15
15
  super
16
- @counter = ProgressCounter.new(notification.count)
16
+ @counter = ProgressCounter.new(notification.count,
17
+ display_line_for_description: ENV.fetch("DISPLAY_LINE_FOR_DESCRIPTION", 10).to_i)
18
+ @output << ProgressFramer.init_display(@counter)
17
19
  end
18
20
 
19
- def example_passed(_notification)
21
+ def example_passed(notification)
20
22
  @counter.passed
23
+ @counter.update_recently_descriptions(notification.example.description, :success)
21
24
  @output << ProgressFramer.display(@counter)
22
25
  end
23
26
 
24
- def example_failed(_notification)
27
+ def example_failed(notification)
25
28
  @counter.failed
29
+ @counter.update_recently_descriptions(notification.example.description, :failure)
26
30
  @output << ProgressFramer.display(@counter)
27
31
  end
28
32
  end
@@ -3,28 +3,35 @@
3
3
  module RSpec
4
4
  module GoGoGo
5
5
  class ProgressCounter
6
- def initialize(total)
6
+ def initialize(total, display_line_for_description: 10)
7
7
  @total = total
8
8
  @passes = 0
9
9
  @failures = 0
10
+ @display_line_for_description = display_line_for_description
11
+ @recently_descriptions = Array.new(display_line_for_description, ["", :success])
10
12
  end
11
- attr_reader :total, :passes, :failures
12
-
13
+ attr_reader :total, :passes, :failures, :recently_descriptions, :display_line_for_description
14
+
13
15
  def passed
14
16
  @passes += 1
15
17
  end
16
-
18
+
17
19
  def failed
18
20
  @failures += 1
19
21
  end
20
-
22
+
21
23
  def checks
22
24
  @passes + @failures
23
25
  end
24
-
26
+
25
27
  def rate
26
28
  (checks.to_f / total).round(2)
27
29
  end
30
+
31
+ def update_recently_descriptions(description, color)
32
+ @recently_descriptions.shift
33
+ @recently_descriptions.push([description, color])
34
+ end
28
35
  end
29
36
  end
30
37
  end
@@ -16,11 +16,31 @@ module RSpec
16
16
  end
17
17
 
18
18
  def terminal_width
19
- `tput cols`.to_i
19
+ @terminal_width ||= `tput cols`.to_i
20
+ end
21
+
22
+ def init_display(counter)
23
+ "\n" * counter.display_line_for_description
20
24
  end
21
25
 
22
26
  def display(counter)
23
- "\r #{result(counter)} #{bar(counter)} #{rate(counter)}"
27
+ move_to_start_position(counter) + display_progress(counter) + display_example_descriptions(counter)
28
+ end
29
+
30
+ def move_to_start_position(counter)
31
+ "\e[#{counter.display_line_for_description}A\r"
32
+ end
33
+
34
+ def display_progress(counter)
35
+ "#{result(counter)} #{bar(counter)} #{rate(counter)}"
36
+ end
37
+
38
+ def display_example_descriptions(counter)
39
+ counter.recently_descriptions.map do |description, color|
40
+ # TODO: It is halved for multibyte characters, but it calculates properly.
41
+ text = description.slice(0, terminal_width / 2)
42
+ "\e[1B\e[0J\r #{RSpec::Core::Formatters::ConsoleCodes.wrap(text, color)}"
43
+ end.join
24
44
  end
25
45
 
26
46
  def bar(counter)
@@ -32,7 +52,7 @@ module RSpec
32
52
  else
33
53
  in_progress_bar(counter, width)
34
54
  end
35
- "|#{progress_bar}|"
55
+ RSpec::Core::Formatters::ConsoleCodes.wrap("|#{progress_bar}|", :magenta)
36
56
  end
37
57
 
38
58
  def result(counter)
@@ -50,10 +70,10 @@ module RSpec
50
70
  "-" * width
51
71
  end
52
72
 
53
- # bar: ====>-----
73
+ # bar: GoGoGo-----
54
74
  def in_progress_bar(counter, width)
55
- bar_len = counter.rate * width.to_f
56
- "#{"=" * (bar_len - 1)}>".ljust(width, "-")
75
+ bar_len = counter.rate * width.to_f / 2
76
+ ("Go" * bar_len).ljust(width, "-")
57
77
  end
58
78
 
59
79
  # bar: ==========
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module GoGoGo
5
- VERSION = "0.1.3"
5
+ VERSION = "1.0.0"
6
6
  end
7
7
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  lib = File.expand_path("lib", __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require "rspec/go_go_go/version"
@@ -35,4 +36,5 @@ Gem::Specification.new do |spec|
35
36
 
36
37
  # For more information and examples about making a new gem, check out our
37
38
  # guide at: https://bundler.io/guides/creating_gem.html
39
+ spec.metadata["rubygems_mfa_required"] = "true"
38
40
  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.3
4
+ version: 1.0.0
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-12 00:00:00.000000000 Z
11
+ date: 2022-12-31 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:
@@ -20,8 +20,6 @@ files:
20
20
  - ".devcontainer/devcontainer.json"
21
21
  - ".rspec"
22
22
  - ".rubocop.yml"
23
- - CHANGELOG.md
24
- - CODE_OF_CONDUCT.md
25
23
  - Gemfile
26
24
  - Gemfile.lock
27
25
  - LICENSE.txt
@@ -33,7 +31,6 @@ files:
33
31
  - lib/rspec/go_go_go/progress_counter.rb
34
32
  - lib/rspec/go_go_go/progress_framer.rb
35
33
  - lib/rspec/go_go_go/version.rb
36
- - progress_framer_spec.rb
37
34
  - rspec-go-go-go.gemspec
38
35
  - sig/rspec_go_go_go.rbs
39
36
  homepage: https://github.com/fukurose/rspec-go-go-go
@@ -43,6 +40,7 @@ metadata:
43
40
  homepage_uri: https://github.com/fukurose/rspec-go-go-go
44
41
  source_code_uri: https://github.com/fukurose/rspec-go-go-go
45
42
  changelog_uri: https://github.com/fukurose/rspec-go-go-go
43
+ rubygems_mfa_required: 'true'
46
44
  post_install_message:
47
45
  rdoc_options: []
48
46
  require_paths:
@@ -58,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
56
  - !ruby/object:Gem::Version
59
57
  version: '0'
60
58
  requirements: []
61
- rubygems_version: 3.3.7
59
+ rubygems_version: 3.3.26
62
60
  signing_key:
63
61
  specification_version: 4
64
62
  summary: run a rspec with progress bar
data/CHANGELOG.md DELETED
@@ -1,5 +0,0 @@
1
- ## [Unreleased]
2
-
3
- ## [0.1.0] - 2022-10-04
4
-
5
- - Initial release
data/CODE_OF_CONDUCT.md DELETED
@@ -1,84 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
-
7
- We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
-
9
- ## Our Standards
10
-
11
- Examples of behavior that contributes to a positive environment for our community include:
12
-
13
- * Demonstrating empathy and kindness toward other people
14
- * Being respectful of differing opinions, viewpoints, and experiences
15
- * Giving and gracefully accepting constructive feedback
16
- * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
- * Focusing on what is best not just for us as individuals, but for the overall community
18
-
19
- Examples of unacceptable behavior include:
20
-
21
- * The use of sexualized language or imagery, and sexual attention or
22
- advances of any kind
23
- * Trolling, insulting or derogatory comments, and personal or political attacks
24
- * Public or private harassment
25
- * Publishing others' private information, such as a physical or email
26
- address, without their explicit permission
27
- * Other conduct which could reasonably be considered inappropriate in a
28
- professional setting
29
-
30
- ## Enforcement Responsibilities
31
-
32
- Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
-
34
- Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
-
36
- ## Scope
37
-
38
- This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
-
40
- ## Enforcement
41
-
42
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at TODO: Write your email address. All complaints will be reviewed and investigated promptly and fairly.
43
-
44
- All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
-
46
- ## Enforcement Guidelines
47
-
48
- Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
-
50
- ### 1. Correction
51
-
52
- **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
-
54
- **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
-
56
- ### 2. Warning
57
-
58
- **Community Impact**: A violation through a single incident or series of actions.
59
-
60
- **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
-
62
- ### 3. Temporary Ban
63
-
64
- **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
-
66
- **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
-
68
- ### 4. Permanent Ban
69
-
70
- **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
-
72
- **Consequence**: A permanent ban from any sort of public interaction within the community.
73
-
74
- ## Attribution
75
-
76
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
- available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
-
79
- Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
-
81
- [homepage]: https://www.contributor-covenant.org
82
-
83
- For answers to common questions about this code of conduct, see the FAQ at
84
- https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
@@ -1,58 +0,0 @@
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