rspec-big-infer 0.5.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 +7 -0
- data/.github/workflows/main.yml +18 -0
- data/.gitignore +11 -0
- data/.rubocop.yml +19 -0
- data/Gemfile +12 -0
- data/LICENSE +21 -0
- data/README.md +18 -0
- data/Rakefile +12 -0
- data/bin/console +11 -0
- data/bin/setup +8 -0
- data/exe/rspec-big-infer +22 -0
- data/lib/rspec/big/infer/formatter.rb +38 -0
- data/lib/rspec/big/infer/version.rb +9 -0
- data/lib/rspec/big/infer.rb +13 -0
- data/publish.sh +5 -0
- data/rspec-big-infer.gemspec +33 -0
- data/sig/rspec/big/infer.rbs +8 -0
- metadata +73 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: db7e04301f8aeda4523f3570a1a6d289c94007a1b2b9b39b0eceff30172f2f41
|
4
|
+
data.tar.gz: 9227adbe57bf51c7e37586260b3008b48fff17f1075c93eb14a9ff6992e8de7d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a5849499d80ad460d82531ce4ad5fc61f4bb3e6678364c11fd673ddb049f6b6f6dc0828327ef6cdcb400c544ef8ea0f0fed4d00e919232bb15a1460b71f740fe
|
7
|
+
data.tar.gz: b17753f2062279b0ca231da662612f19eb30b7d4639c2870647b971dba515cf60a86b16115f8198d617f138c34f73cfc4c7bd95b372674941525a80a7401b481
|
@@ -0,0 +1,18 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on: [push,pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
steps:
|
9
|
+
- uses: actions/checkout@v2
|
10
|
+
- name: Set up Ruby
|
11
|
+
uses: ruby/setup-ruby@v1
|
12
|
+
with:
|
13
|
+
ruby-version: 2.5.7
|
14
|
+
- name: Run the default task
|
15
|
+
run: |
|
16
|
+
gem install bundler -v 2.2.14
|
17
|
+
bundle install
|
18
|
+
bundle exec rake
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.4
|
3
|
+
NewCops: enable
|
4
|
+
Include:
|
5
|
+
- 'exe/**/*'
|
6
|
+
|
7
|
+
Style/StringLiterals:
|
8
|
+
Enabled: true
|
9
|
+
EnforcedStyle: double_quotes
|
10
|
+
|
11
|
+
Style/StringLiteralsInInterpolation:
|
12
|
+
Enabled: true
|
13
|
+
EnforcedStyle: double_quotes
|
14
|
+
|
15
|
+
Layout/LineLength:
|
16
|
+
Max: 120
|
17
|
+
|
18
|
+
Style/MultilineBlockChain:
|
19
|
+
Enabled: false
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2022 iPePe.pl Open Source Software
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Rspec::Big::Infer
|
2
|
+
|
3
|
+
`rspec-big-infer` is a set of helper tools that help working (testing) with big projects.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Execute this command to add gem to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
bundle add rspec-big-infer
|
11
|
+
```
|
12
|
+
|
13
|
+
## Usage - infer which tests to run based on the changes in the codebase
|
14
|
+
|
15
|
+
1. Generate tests map with: `bundle exec rspec --dry-run --format Rspec::Big::Infer::Formatter --out tmp/rspec_infer.json`
|
16
|
+
* It works based on `described_class` and `const_source_location`
|
17
|
+
2. (optional) Printout tests that will be run based on infer: `git diff --name-only --diff-filter=D origin/develop | bundle exec rspec-big-infer tmp/rspec_infer.json`
|
18
|
+
3. Run tests with `bundle exec rspec $(git diff --name-only --diff-filter=D origin/develop | bundle exec rspec-big-infer tmp/rspec_infer.json)` to run tests based on the changes in the codebase.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "rspec/big/infer"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
require "irb"
|
11
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/rspec-big-infer
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
# Load the examples from the JSON file
|
7
|
+
if ARGV[0]
|
8
|
+
path = ARGV[0]
|
9
|
+
all_rspec_examples = JSON.parse(File.read(path))["examples"]
|
10
|
+
changed_files = $stdin.read.split("\n")
|
11
|
+
|
12
|
+
all_rspec_examples.compact.uniq.each do |test|
|
13
|
+
if changed_files.include?(test["described_class_defined_source_location"]) ||
|
14
|
+
changed_files.include?(test["test_file_path"])
|
15
|
+
puts test["test_file_path"]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
else
|
20
|
+
warn "Usage: git diff --name-only origin/develop | rspec-big-infer <path to JSON test map file>"
|
21
|
+
exit 1
|
22
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rspec/core/formatters/json_formatter"
|
4
|
+
|
5
|
+
module Rspec
|
6
|
+
module Big
|
7
|
+
module Infer
|
8
|
+
class Formatter < RSpec::Core::Formatters::JsonFormatter
|
9
|
+
::RSpec::Core::Formatters.register self
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def format_example(example)
|
14
|
+
return unless example.example_group.described_class.is_a?(Class)
|
15
|
+
|
16
|
+
{
|
17
|
+
test_file_path: relative_path(example.file_path),
|
18
|
+
described_class_defined_source_location: source_location(example.example_group.described_class),
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def source_location(klass)
|
23
|
+
relative_path(klass.const_source_location(klass.name).first)
|
24
|
+
end
|
25
|
+
|
26
|
+
def relative_path(path)
|
27
|
+
if path.start_with?('./')
|
28
|
+
path.sub('./', '')
|
29
|
+
elsif path.start_with?('/')
|
30
|
+
path.sub(%r{^#{Dir.pwd}/}, '')
|
31
|
+
else
|
32
|
+
path
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/publish.sh
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/rspec/big/infer/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "rspec-big-infer"
|
7
|
+
spec.version = Rspec::Big::Infer::VERSION
|
8
|
+
spec.authors = ["Patryk Ptasinski"]
|
9
|
+
spec.email = ["patryk@ipepe.pl"]
|
10
|
+
|
11
|
+
spec.summary = "Infer which RSpec test files to run based on currently changed files"
|
12
|
+
spec.homepage = "https://github.com/ipepe-oss/rspec-big-infer"
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.1.0")
|
14
|
+
|
15
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
19
|
+
spec.metadata["changelog_uri"] = spec.homepage
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = ["rspec-big-infer"]
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
spec.add_dependency "rspec-core", "~> 3"
|
30
|
+
|
31
|
+
# For more information and examples about making a new gem, checkout our
|
32
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec-big-infer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Patryk Ptasinski
|
8
|
+
bindir: exe
|
9
|
+
cert_chain: []
|
10
|
+
date: 2025-05-21 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: rspec-core
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - "~>"
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '3'
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - "~>"
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '3'
|
26
|
+
email:
|
27
|
+
- patryk@ipepe.pl
|
28
|
+
executables:
|
29
|
+
- rspec-big-infer
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- ".github/workflows/main.yml"
|
34
|
+
- ".gitignore"
|
35
|
+
- ".rubocop.yml"
|
36
|
+
- Gemfile
|
37
|
+
- LICENSE
|
38
|
+
- README.md
|
39
|
+
- Rakefile
|
40
|
+
- bin/console
|
41
|
+
- bin/setup
|
42
|
+
- exe/rspec-big-infer
|
43
|
+
- lib/rspec/big/infer.rb
|
44
|
+
- lib/rspec/big/infer/formatter.rb
|
45
|
+
- lib/rspec/big/infer/version.rb
|
46
|
+
- publish.sh
|
47
|
+
- rspec-big-infer.gemspec
|
48
|
+
- sig/rspec/big/infer.rbs
|
49
|
+
homepage: https://github.com/ipepe-oss/rspec-big-infer
|
50
|
+
licenses: []
|
51
|
+
metadata:
|
52
|
+
allowed_push_host: https://rubygems.org
|
53
|
+
homepage_uri: https://github.com/ipepe-oss/rspec-big-infer
|
54
|
+
source_code_uri: https://github.com/ipepe-oss/rspec-big-infer
|
55
|
+
changelog_uri: https://github.com/ipepe-oss/rspec-big-infer
|
56
|
+
rdoc_options: []
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 2.1.0
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
requirements: []
|
70
|
+
rubygems_version: 3.6.2
|
71
|
+
specification_version: 4
|
72
|
+
summary: Infer which RSpec test files to run based on currently changed files
|
73
|
+
test_files: []
|