quick_check 0.1.0 → 0.1.1

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: 896e5b8930fe9d6f9c090ef32c1bbc70a57a05d415c7ad6996e5a4e211868963
4
- data.tar.gz: ae0e8f1831e674357081df078d68cfdbf3966c22d09f6c826becaa7d6a21bd90
3
+ metadata.gz: 4ea26165117cca41f73e40de4f2975ac21bfa9d86b3d097dabfe43fbf3147416
4
+ data.tar.gz: 85d0174ff222df297448f18b3d6333b2cecc6aec6a82afacd86076568843f9f0
5
5
  SHA512:
6
- metadata.gz: cddc454b92ad6e3c2c1f9afe08dab40305c9ee29bfe91d35a44fe578b7c52bb27cc09dbd1806c13d6cb9350bb4e945a0e2e1c24c757bbb005865739b2cd9281f
7
- data.tar.gz: 7952bbeb5140d87b51b189b464ee7309367a49fc687e099bdcd124b9d5744b0914735d0336b36d500a6dbe781b2bae5101101519a9446af319f2bbb442256fc4
6
+ metadata.gz: 4c4631164f1ce412d3ee1c3ee1d100197ea2311c3ea28d246a3edc3854466194670a4faabcfae939e44c97caeed2552ed1a5cc1e09f9b5ec46c0f307d82bfe1b
7
+ data.tar.gz: 48b7538d2f0600a3381d8847eeab3455630612a715f0dbe70d996cd312fb9b7c15bd05083323eb9cc9f0eab788e1f40452dfa10332f623ef30ac9381c268d4e2
data/README.md CHANGED
@@ -99,10 +99,10 @@ If no config is present, `qc` will use the first existing branch among `main` or
99
99
 
100
100
  ## How it works
101
101
 
102
- - Unstaged: `git diff --name-only --diff-filter=ACMR`
103
- - Staged: `git diff --name-only --cached --diff-filter=ACMR`
102
+ - Unstaged: `git diff --name-only --diff-filter=AM`
103
+ - Staged: `git diff --name-only --cached --diff-filter=AM`
104
104
  - Untracked: `git ls-files --others --exclude-standard`
105
- - Committed vs base: `git diff --name-only --diff-filter=ACMR <base>...HEAD`
105
+ - Committed vs base: `git diff --name-only --diff-filter=AM <base>...HEAD`
106
106
 
107
107
  Files are filtered to `spec/**/*_spec.rb` and/or `test/**/*_test.rb`, de-duplicated, sorted, and then:
108
108
 
@@ -17,7 +17,7 @@ module QuickCheck
17
17
  @argv = argv
18
18
  @options = {
19
19
  base_branch: nil,
20
- include_committed_diff: true,
20
+ include_committed_diff: false,
21
21
  include_staged: true,
22
22
  include_unstaged: true,
23
23
  custom_command: nil,
@@ -126,12 +126,12 @@ module QuickCheck
126
126
  files = []
127
127
 
128
128
  if @options[:include_unstaged]
129
- files.concat(git_diff_name_only(["--name-only", "--diff-filter=ACMR"]))
129
+ files.concat(git_diff_name_only(["--name-only", "--diff-filter=AM"]))
130
130
  files.concat(git_untracked_files)
131
131
  end
132
132
 
133
133
  if @options[:include_staged]
134
- files.concat(git_diff_name_only(["--name-only", "--cached", "--diff-filter=ACMR"]))
134
+ files.concat(git_diff_name_only(["--name-only", "--cached", "--diff-filter=AM"]))
135
135
  end
136
136
 
137
137
  if @options[:include_committed_diff]
@@ -139,7 +139,7 @@ module QuickCheck
139
139
  if current_branch && base_branch && current_branch != base_branch
140
140
  # Include files changed on this branch vs base
141
141
  range = diff_range_against_base(base_branch)
142
- files.concat(git_diff_name_only(["--name-only", "--diff-filter=ACMR", range])) if range
142
+ files.concat(git_diff_name_only(["--name-only", "--diff-filter=AM", range])) if range
143
143
  end
144
144
  end
145
145
 
@@ -147,16 +147,7 @@ module QuickCheck
147
147
  rspec_specs = files.select { |f| f.match?(%r{\Aspec/.+_spec\.rb\z}) }
148
148
  minitest_tests = files.select { |f| f.match?(%r{\Atest/.+_test\.rb\z}) }
149
149
 
150
- # Infer tests from source changes (e.g., app/models/user.rb -> spec/models/user_spec.rb)
151
- source_files = files.reject { |f| f.match?(%r{\A(spec/|test/)}) }
152
- unless source_files.empty?
153
- inferred_rspec = source_files.flat_map { |src| infer_rspec_paths_for_source(src) }
154
- inferred_minitest = source_files.flat_map { |src| infer_minitest_paths_for_source(src) }
155
- rspec_specs.concat(inferred_rspec)
156
- minitest_tests.concat(inferred_minitest)
157
- end
158
-
159
- { rspec: rspec_specs.uniq, minitest: minitest_tests.uniq }
150
+ { rspec: rspec_specs.sort, minitest: minitest_tests.sort }
160
151
  end
161
152
 
162
153
  def ensure_git_repo!
@@ -224,10 +215,12 @@ module QuickCheck
224
215
  end
225
216
 
226
217
  def diff_range_against_base(base)
227
- return nil unless branch_exists?(base)
228
- # If upstream exists, prefer merge-base to HEAD to include all branch commits
229
- # The symmetric range base...HEAD ensures we include commits unique to the branch
230
- "#{base}...HEAD"
218
+ # Prefer the symmetric range base...HEAD if base exists
219
+ if branch_exists?(base)
220
+ "#{base}...HEAD"
221
+ else
222
+ nil
223
+ end
231
224
  end
232
225
 
233
226
  def git_diff_name_only(args)
@@ -245,52 +238,6 @@ module QuickCheck
245
238
  out.split("\n").map(&:strip).reject(&:empty?)
246
239
  end
247
240
 
248
- def infer_rspec_paths_for_source(source_path)
249
- candidates = []
250
- if source_path.start_with?("app/")
251
- rel = source_path.sub(/^app\//, "")
252
- # Prefer request specs for controllers
253
- if rel.start_with?("controllers/")
254
- sub_rel = rel.sub(/^controllers\//, "")
255
- dir = File.dirname(sub_rel)
256
- dir = "" if dir == "."
257
- base_with_controller = File.basename(sub_rel, ".rb")
258
- base_without_controller = base_with_controller.sub(/_controller\z/, "")
259
- # Common conventions for request specs
260
- candidates << File.join("spec", "requests", dir, "#{base_without_controller}_spec.rb")
261
- candidates << File.join("spec", "requests", dir, "#{base_with_controller}_spec.rb")
262
- end
263
- candidates << File.join("spec", rel).sub(/\.rb\z/, "_spec.rb")
264
- elsif source_path.start_with?("lib/")
265
- rel = source_path.sub(/^lib\//, "")
266
- candidates << File.join("spec", "lib", rel).sub(/\.rb\z/, "_spec.rb")
267
- end
268
-
269
- candidates.select { |p| File.file?(p) }
270
- end
271
-
272
- def infer_minitest_paths_for_source(source_path)
273
- candidates = []
274
- if source_path.start_with?("app/")
275
- rel = source_path.sub(/^app\//, "")
276
- # Prefer integration/request-style tests for controllers when present
277
- if rel.start_with?("controllers/")
278
- sub_rel = rel.sub(/^controllers\//, "")
279
- dir = File.dirname(sub_rel)
280
- dir = "" if dir == "."
281
- base = File.basename(sub_rel, ".rb").sub(/_controller\z/, "")
282
- integration_test = File.join("test", "integration", dir, "#{base}_test.rb")
283
- candidates << integration_test
284
- end
285
- candidates << File.join("test", rel).sub(/\.rb\z/, "_test.rb")
286
- elsif source_path.start_with?("lib/")
287
- rel = source_path.sub(/^lib\//, "")
288
- candidates << File.join("test", "lib", rel).sub(/\.rb\z/, "_test.rb")
289
- end
290
-
291
- candidates.select { |p| File.file?(p) }
292
- end
293
-
294
241
  def build_command_for(framework, files)
295
242
  return (@options[:custom_command] + files) if @options[:custom_command]
296
243
 
@@ -310,13 +257,11 @@ module QuickCheck
310
257
  end
311
258
 
312
259
  def rails_available?
313
- bin_rails = File.join(Dir.pwd, "bin", "rails")
314
- File.executable?(bin_rails) || File.file?(bin_rails) || gemfile_includes?("rails")
260
+ File.executable?(File.join(Dir.pwd, "bin", "rails")) || gemfile_includes?("rails")
315
261
  end
316
262
 
317
263
  def rails_cmd
318
- bin_rails = File.join(Dir.pwd, "bin", "rails")
319
- if File.executable?(bin_rails) || File.file?(bin_rails)
264
+ if File.executable?(File.join(Dir.pwd, "bin", "rails"))
320
265
  [File.join("bin", "rails")]
321
266
  else
322
267
  ["bundle", "exec", "rails"]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module QuickCheck
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quick_check
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
  - Kasvit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-08-22 00:00:00.000000000 Z
11
+ date: 2025-08-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Adds the `qc` command to run only changed or newly added RSpec files
14
14
  from uncommitted changes and vs base branch (main/master).