rails-quality-assurance 1.1.2 → 1.2.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 +4 -4
- data/CHANGELOG.md +21 -0
- data/README.md +24 -2
- data/lib/rails_quality_assurance/rails/helper.rb +100 -0
- data/lib/rails_quality_assurance/rails_helper.rb +4 -0
- data/lib/rails_quality_assurance/rails_test_helper.rb +4 -0
- data/lib/rails_quality_assurance/version.rb +1 -1
- metadata +4 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fbfaa2ba084f177367b0e73824321a2367d320af6063f7cd566ada9667955b6a
|
|
4
|
+
data.tar.gz: d6e96d0197b9ed90e59fce7ca6aeb816e8fdc6591651d96d3cb6888e572a3c48
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d4ea679306eded2575e31dd73f5e92e57094c909b9936ff6408a2425c8b0cae1a28429ec21770dfe1edd17324cb2878311d3a3b164b88839575414fb9f62b70c
|
|
7
|
+
data.tar.gz: 5f7a613b6185e7ce0873b06a3f7d87d18a88db874679831908754c6f403489734224589c998347030298a2b647aa7e89c84fb864f6c17c6524b5f912bda336b8
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,27 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.2.0] - 2026-09-14
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `rails_quality_assurance/rails_helper`: one require applying the shared Rails
|
|
13
|
+
test configuration (schema check, transactional fixtures, spec-type inference,
|
|
14
|
+
Rails backtrace filtering, FactoryBot, time helpers, WebMock lockdown with a
|
|
15
|
+
loopback/Playwright allowlist, I18n locale, Faker reset, CSRF toggle).
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- SimpleCov upgraded to 1.3 with explicit `finalize_merge` so parallel workers
|
|
20
|
+
enforce thresholds exactly once.
|
|
21
|
+
- QA rake tasks live under `qa:` and no longer boot the Rails environment, so a
|
|
22
|
+
lint-only CI job passes without native image libraries.
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- Packaged Biome/Stylelint configs renamed to avoid colliding with an app's root
|
|
27
|
+
configuration when the gem sits under `vendor/bundle`.
|
|
28
|
+
|
|
8
29
|
## [1.0.0] - 2026-09-14
|
|
9
30
|
|
|
10
31
|
### Added
|
data/README.md
CHANGED
|
@@ -80,7 +80,29 @@ That single require sets up:
|
|
|
80
80
|
|
|
81
81
|
*(If you prefer to load them individually, `require 'rails_quality_assurance/simplecov'` and `require 'rails_quality_assurance/playwright'` remain available.)*
|
|
82
82
|
|
|
83
|
-
### 3.
|
|
83
|
+
### 3. Rails Test Setup (spec/rails_helper.rb)
|
|
84
|
+
|
|
85
|
+
After the Rails environment boots, one require applies the shared Rails test configuration:
|
|
86
|
+
|
|
87
|
+
```ruby
|
|
88
|
+
require 'spec_helper'
|
|
89
|
+
require_relative '../config/environment'
|
|
90
|
+
require 'rails_quality_assurance/rails_helper'
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
That sets up, without any boilerplate in the app:
|
|
94
|
+
|
|
95
|
+
- `ActiveRecord::Migration.maintain_test_schema!` (aborts on pending migrations)
|
|
96
|
+
- `use_transactional_fixtures`, fixture paths, and `infer_spec_type_from_file_location!`
|
|
97
|
+
- `filter_rails_from_backtrace!`
|
|
98
|
+
- FactoryBot syntax methods and ActiveSupport time helpers
|
|
99
|
+
- WebMock network lockdown with a loopback + Playwright allowlist
|
|
100
|
+
- `I18n.locale = :en` before each example; `Faker::UniqueGenerator` reset after each
|
|
101
|
+
- CSRF forgery protection toggled on around system specs
|
|
102
|
+
|
|
103
|
+
Application-specific setup (auth helpers, custom matchers, gateway stubs) stays in the app's own `rails_helper.rb`.
|
|
104
|
+
|
|
105
|
+
### 4. Continuous Integration: `bin/ci`
|
|
84
106
|
|
|
85
107
|
Run the generator to install `bin/ci` and `config/ci.rb`:
|
|
86
108
|
|
|
@@ -100,7 +122,7 @@ Or in Docker-based setups:
|
|
|
100
122
|
bin/run bin/ci
|
|
101
123
|
```
|
|
102
124
|
|
|
103
|
-
###
|
|
125
|
+
### 5. Rake Tasks (Optional)
|
|
104
126
|
|
|
105
127
|
The gem also provides tasks if you prefer `rake`:
|
|
106
128
|
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'uri'
|
|
4
|
+
|
|
5
|
+
module RailsQualityAssurance
|
|
6
|
+
# Applies the Rails-specific RSpec configuration shared by every Develoz app.
|
|
7
|
+
#
|
|
8
|
+
# Loaded from spec/rails_helper.rb, after the Rails environment boots:
|
|
9
|
+
#
|
|
10
|
+
# # spec/rails_helper.rb
|
|
11
|
+
# require 'spec_helper'
|
|
12
|
+
# require_relative '../config/environment'
|
|
13
|
+
# require 'rails_quality_assurance/rails_helper'
|
|
14
|
+
module RailsHelper
|
|
15
|
+
def self.configure!
|
|
16
|
+
return unless defined?(RSpec)
|
|
17
|
+
|
|
18
|
+
verify_schema!
|
|
19
|
+
RSpec.configure do |config|
|
|
20
|
+
configure_fixtures(config)
|
|
21
|
+
configure_includes(config)
|
|
22
|
+
configure_network(config)
|
|
23
|
+
configure_locale(config)
|
|
24
|
+
configure_forgery_protection(config)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def self.verify_schema!
|
|
29
|
+
return unless defined?(ActiveRecord::Migration)
|
|
30
|
+
|
|
31
|
+
ActiveRecord::Migration.maintain_test_schema!
|
|
32
|
+
rescue ActiveRecord::PendingMigrationError => e
|
|
33
|
+
Kernel.abort(e.to_s.strip)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.configure_fixtures(config)
|
|
37
|
+
return unless rspec_rails?
|
|
38
|
+
|
|
39
|
+
config.fixture_paths = [fixtures_path].compact if fixtures_path
|
|
40
|
+
config.use_transactional_fixtures = true
|
|
41
|
+
config.infer_spec_type_from_file_location!
|
|
42
|
+
config.filter_rails_from_backtrace!
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def self.fixtures_path
|
|
46
|
+
return nil unless defined?(Rails)
|
|
47
|
+
|
|
48
|
+
Rails.root.join('spec/fixtures')
|
|
49
|
+
rescue NoMethodError
|
|
50
|
+
nil
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def self.rspec_rails?
|
|
54
|
+
defined?(RSpec::Rails)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def self.configure_includes(config)
|
|
58
|
+
config.include FactoryBot::Syntax::Methods if defined?(FactoryBot)
|
|
59
|
+
config.include ActiveSupport::Testing::TimeHelpers if defined?(ActiveSupport::Testing::TimeHelpers)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def self.configure_network(config)
|
|
63
|
+
return unless defined?(WebMock)
|
|
64
|
+
|
|
65
|
+
allowed = localhost_hosts
|
|
66
|
+
config.before { WebMock.disable_net_connect!(allow: allowed) }
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Hosts the suite may reach without stubbing: the Playwright server when
|
|
70
|
+
# system specs run remotely, plus loopback.
|
|
71
|
+
def self.localhost_hosts
|
|
72
|
+
[playwright_host, 'localhost', '0.0.0.0', '127.0.0.1'].compact.uniq.freeze
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def self.playwright_host
|
|
76
|
+
url = ENV.fetch('PLAYWRIGHT_URL', nil)
|
|
77
|
+
return nil if url.blank?
|
|
78
|
+
|
|
79
|
+
URI.parse(url).host
|
|
80
|
+
rescue URI::InvalidURIError
|
|
81
|
+
nil
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def self.configure_locale(config)
|
|
85
|
+
config.before { I18n.locale = :en } if defined?(I18n)
|
|
86
|
+
config.after { Faker::UniqueGenerator.clear } if defined?(Faker)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def self.configure_forgery_protection(config)
|
|
90
|
+
return unless defined?(ActionController::Base)
|
|
91
|
+
|
|
92
|
+
config.around(:each, type: :system) do |example|
|
|
93
|
+
ActionController::Base.allow_forgery_protection = true
|
|
94
|
+
example.run
|
|
95
|
+
ensure
|
|
96
|
+
ActionController::Base.allow_forgery_protection = false
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails-quality-assurance
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mauricio Zaffari
|
|
@@ -355,6 +355,9 @@ files:
|
|
|
355
355
|
- lib/rails_quality_assurance/ci_runner.rb
|
|
356
356
|
- lib/rails_quality_assurance/playwright.rb
|
|
357
357
|
- lib/rails_quality_assurance/playwright/helper.rb
|
|
358
|
+
- lib/rails_quality_assurance/rails/helper.rb
|
|
359
|
+
- lib/rails_quality_assurance/rails_helper.rb
|
|
360
|
+
- lib/rails_quality_assurance/rails_test_helper.rb
|
|
358
361
|
- lib/rails_quality_assurance/railtie.rb
|
|
359
362
|
- lib/rails_quality_assurance/rspec.rb
|
|
360
363
|
- lib/rails_quality_assurance/rspec/helper.rb
|