|
2 | 2 |
|
3 | 3 | return unless defined?(Prosopite) |
4 | 4 |
|
5 | | -# Test configuration |
| 5 | +# Test configuration — this file owns all Prosopite settings for the test env |
6 | 6 | Prosopite.enabled = true |
7 | | -Prosopite.raise = false # Log only, don't fail specs |
| 7 | +Prosopite.raise = true |
8 | 8 | Prosopite.rails_logger = true |
9 | 9 | Prosopite.prosopite_logger = true |
10 | 10 |
|
|
16 | 16 | "shoulda/matchers/active_model/allow_value_matcher.rb" |
17 | 17 | ] |
18 | 18 |
|
19 | | -# Optional: Load ignore list from file for gradual rollout |
| 19 | +# Load ignore list from file for gradual rollout — directories listed in |
| 20 | +# .prosopite_ignore are scanned but won't raise, only log. |
20 | 21 | PROSOPITE_IGNORE = if File.exist?("spec/.prosopite_ignore") |
21 | | - File.read("spec/.prosopite_ignore").lines.map(&:chomp).reject(&:empty?) |
| 22 | + File.read("spec/.prosopite_ignore") |
| 23 | + .lines |
| 24 | + .map(&:chomp) |
| 25 | + .reject { |line| line.empty? || line.start_with?("#") } |
22 | 26 | else |
23 | 27 | [] |
24 | 28 | end |
25 | 29 |
|
26 | | -# Monkey-patch FactoryBot to pause during factory creation |
27 | | -# Prevents false positives from factory callbacks |
28 | | -if defined?(FactoryBot) |
29 | | - module FactoryBot |
30 | | - module Strategy |
31 | | - class Create |
32 | | - alias_method :original_result, :result |
| 30 | +RSpec.configure do |config| |
| 31 | + # Pause Prosopite during factory creation to prevent false positives |
| 32 | + # from factory callbacks and associations |
| 33 | + config.before(:suite) do |
| 34 | + if defined?(FactoryBot) |
| 35 | + FactoryBot::SyntaxRunner.class_eval do |
| 36 | + alias_method :original_create, :create |
33 | 37 |
|
34 | | - def result(evaluation) |
| 38 | + def create(*args, **kwargs, &block) |
35 | 39 | if defined?(Prosopite) && Prosopite.enabled? |
36 | | - Prosopite.pause { original_result(evaluation) } |
| 40 | + Prosopite.pause { original_create(*args, **kwargs, &block) } |
37 | 41 | else |
38 | | - original_result(evaluation) |
| 42 | + original_create(*args, **kwargs, &block) |
39 | 43 | end |
40 | 44 | end |
41 | 45 | end |
42 | 46 | end |
43 | 47 | end |
44 | | -end |
45 | 48 |
|
46 | | -# RSpec integration |
47 | | -RSpec.configure do |config| |
48 | 49 | config.around do |example| |
49 | 50 | if use_prosopite?(example) |
50 | 51 | Prosopite.scan { example.run } |
|
0 commit comments