lesli_testing 1.2.3 → 1.3.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: d3f8b488a261e18bdf9030e0c369c534cd987341222892b3f397467ab382998b
4
- data.tar.gz: bc20743265959a07b2acd5b1975b4d59eb9e30ab612d40621c1b8ccc1a86648e
3
+ metadata.gz: bdacbd0fd03af65afdbaed58961bd85ecf8d1a1868af0f4aeddf9867245767c0
4
+ data.tar.gz: 789586b828f9bf72666eba3a017e58213d17ad1cca1ee398e109a3dcbd9db28f
5
5
  SHA512:
6
- metadata.gz: 17f37531c01a9a60131c69bd6cb87c6b4cb8b9a56ab54ddf1cfc04520fda3eb2f03d998f4b1c814ff4f29813ffb93280dbc940a28ba5b23de18d7b81c6b0861b
7
- data.tar.gz: e29091cc308623a4f80d4423968c22d6882785dbf4712441567e3435e56f7fc1839e3120e6409fab285542fdae81d532ba364e71e29cea3efc18cfcb3c04f961
6
+ metadata.gz: a0a8abf6b75c318a8c8246c9b304926115d1105b5f667bcd33b245905501363dcb1fb042bb09f0240c17a5a738cd69032214cba941ac32f3a9e1dc589ec62df4
7
+ data.tar.gz: b0e95f307cf5422ec7425aaf0466da0024dcdafd743f371b8c26d9a9bb13751a161366f5696b284f0c7208842919564f2214a88e996b06a1206cfadc4387b55d
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  =begin
2
4
 
3
5
  Lesli
@@ -30,43 +32,38 @@ Building a better future, one line of code at a time.
30
32
  // ·
31
33
  =end
32
34
 
35
+
36
+ # Load code coverage tools
37
+ require "simplecov"
38
+ require "simplecov-html"
39
+ require "simplecov-console"
40
+ require "simplecov-cobertura"
41
+ require_relative "simplecov/profiles"
42
+
43
+
33
44
  module LesliTesting
34
45
  module Coverage
35
- def self.start(engine_name = "Lesli", min_coverage = 40)
36
- return unless ENV["COVERAGE"]
37
-
38
- # Add coverage formatters
39
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
40
- SimpleCov::Formatter::CoberturaFormatter,
41
- SimpleCov::Formatter::Console
42
- ])
43
-
44
- # Define the limit to allow missing tested code
45
- SimpleCov::Formatter::Console.missing_len = 10
46
-
47
- SimpleCov.start "rails" do
48
- command_name engine_name
49
-
50
- # Standard filters for all Lesli engines
51
- add_filter [
52
- "/app/assets",
53
- "/app/jobs",
54
- "/config",
55
- "/docs",
56
- "/db",
57
- "/test",
58
- "/test/dummy/",
59
- "/lib/tasks",
60
- "/vendor"
61
- ]
62
-
63
- # Add your groups
64
- add_group "Models", "app/models"
65
- add_group "Services", "app/services"
66
- add_group "Controllers", "app/controllers"
67
-
68
- # Minimum expected coverage percentage
69
- minimum_coverage min_coverage
46
+ class << self
47
+
48
+ def start(app_name, profile:"rails", min_coverage:90, missing_len:25)
49
+
50
+ # Add coverage formatters
51
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
52
+ SimpleCov::Formatter::CoberturaFormatter,
53
+ SimpleCov::Formatter::HTMLFormatter,
54
+ SimpleCov::Formatter::Console
55
+ ])
56
+
57
+ # Define the limit to allow missing tested code
58
+ SimpleCov::Formatter::Console.missing_len = missing_len
59
+
60
+ SimpleCov.start "lesli_rails_#{profile}" do
61
+
62
+ command_name(app_name)
63
+
64
+ # Minimum expected coverage percentage
65
+ minimum_coverage(min_coverage)
66
+ end
70
67
  end
71
68
  end
72
69
  end
@@ -0,0 +1,72 @@
1
+ =begin
2
+
3
+ Lesli
4
+
5
+ Copyright (c) 2026, Lesli Technologies, S. A.
6
+
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see http://www.gnu.org/licenses/.
19
+
20
+ Lesli · Ruby on Rails SaaS Development Framework.
21
+
22
+ Made with ♥ by LesliTech
23
+ Building a better future, one line of code at a time.
24
+
25
+ @contact hello@lesli.tech
26
+ @website https://www.lesli.tech
27
+ @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
+
29
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
+ // ·
31
+ =end
32
+
33
+ module LesliTesting
34
+ module Fixtures
35
+ class << self
36
+ def load_fixtures_for_lesli()
37
+
38
+ if defined?(Lesli)
39
+ ActiveSupport.on_load(:active_support_test_case) do
40
+ # En Rails 8, usamos ActiveRecord::TestFixtures si está disponible
41
+ include ActiveRecord::TestFixtures if defined?(ActiveRecord::TestFixtures)
42
+
43
+ lesli_fixtures = Lesli::Engine.root.join("test", "fixtures").to_s
44
+ lesli_files = Lesli::Engine.root.join("test", "fixtures", "files").to_s
45
+
46
+ # Rails 8 usa fixture_paths (plural) como el estándar
47
+ # Pero para evitar el NoMethodError, lo asignamos de forma segura:
48
+ if respond_to?(:fixture_paths=)
49
+ # Combinamos las rutas existentes con la nueva del Engine
50
+ self.fixture_paths |= [ lesli_fixtures ]
51
+ else
52
+ # Fallback por si la carga de ActiveRecord se retrasa
53
+ class_attribute :fixture_paths, default: [ lesli_fixtures ]
54
+ end
55
+
56
+ # Los archivos adjuntos (Active Storage, etc)
57
+ self.file_fixture_path = lesli_files
58
+
59
+ # IMPORTANT: attach fixture sets to namespaced models BEFORE loading fixtures
60
+ self.set_fixture_class(
61
+ lesli_users: "Lesli::User",
62
+ lesli_accounts: "Lesli::Account"
63
+ )
64
+ end
65
+ end
66
+ end
67
+
68
+ def load_fixtures_for_engine(engine_module)
69
+ end
70
+ end
71
+ end
72
+ end
@@ -1,6 +1,34 @@
1
+ =begin
1
2
 
2
- # lib/lesli_testing/reporters/cli_reporter.rb
3
- require "minitest"
3
+ Lesli
4
+
5
+ Copyright (c) 2026, Lesli Technologies, S. A.
6
+
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see http://www.gnu.org/licenses/.
19
+
20
+ Lesli · Ruby on Rails SaaS Development Framework.
21
+
22
+ Made with ♥ by LesliTech
23
+ Building a better future, one line of code at a time.
24
+
25
+ @contact hello@lesli.tech
26
+ @website https://www.lesli.tech
27
+ @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
+
29
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
+ // ·
31
+ =end
4
32
 
5
33
  module LesliTesting
6
34
  module Reporters
@@ -136,41 +164,75 @@ module LesliTesting
136
164
  Termline.br
137
165
  end
138
166
 
139
- def parse_minitest_assertion_messages2 message
140
- msg = message.strip
141
- return Termline::Style.colorize(" + #{msg}", :green) if msg.start_with? "Expected:"
142
- return Termline::Style.colorize(" - #{msg}", :red) if msg.start_with? "Actual:"
143
- return Termline::Style.colorize(" #{Termline::Style.icon(:warning)} #{msg}", :yellow)
144
- end
145
-
146
167
  def parse_minitest_assertion_messages(message)
147
- msg = message.strip
148
-
149
- case msg
150
-
151
- # 1. Boolean/Nil Failures (e.g., "Expected true to be nil" or "Expected false to be truthy")
152
- when /Expected (.*) to be (nil|truthy|falsey)/, /Expected (.*) to be (.*)/
153
- Termline::Style.colorize(" #{Termline::Style.icon(:info)} #{msg}", :skyblue)
154
-
155
- # 2. Standard Diffs (Expected vs Actual)
156
- when /^Expected:?\s+/
157
- Termline::Style.colorize(" #{Termline::Style.icon(:add)} #{msg}", :green)
158
-
159
- when /^Actual:?\s+/
160
- Termline::Style.colorize(" #{Termline::Style.icon(:remove)} #{msg}", :red)
161
-
162
- # 3. Rails Difference Failures (e.g., "User.count" didn't change by 1)
163
- when /"(.*)" didn't change by (.*)/, /actual change was (.*)/
164
- Termline::Style.colorize(" #{Termline::Style.icon(:warning)} #{msg}", :yellow)
165
-
166
- # 4. Collection/Count Failures (e.g., Expected 5 elements, found 2)
167
- when /Expected (.*) elements?, found (.*)/, /Expected exactly (.*) nodes/
168
- Termline::Style.colorize(" #{Termline::Style.icon(:list)} #{msg}", :magenta)
169
-
170
- # 5. Fallback for custom messages (anything else)
171
- else
172
- Termline::Style.colorize(" #{Termline::Style.icon(:arrow_right)} #{msg}", :gray)
173
- end
168
+ message.to_s.rstrip.lines.map do |line|
169
+ msg = line.strip
170
+
171
+ case msg
172
+
173
+ # 1. Unified Diff Headers
174
+ # Covers Minitest diff output like:
175
+ # --- expected
176
+ # +++ actual
177
+ # @@ -1 +1 @@
178
+ when /^--- /
179
+ Termline::Style.colorize("#{msg}:", :red)
180
+
181
+ when /^\+\+\+ /
182
+ Termline::Style.colorize("++#{msg}:", :green)
183
+
184
+ when /^@@ /
185
+ Termline::Style.colorize("#{msg}", :skyblue)
186
+
187
+ # 2. Unified Diff Content Lines
188
+ # Covers actual changed lines inside the diff, like:
189
+ # -[:lesli_support_item_tasks, "lesli_support"]
190
+ # +[:lesli_support_items_tasks, "lesli_support"]
191
+ # The negative lookahead avoids matching the diff headers above.
192
+ when /^-(?!-)/
193
+ Termline::Style.colorize(" #{Termline::Style.icon(:remove)}-#{msg}", :red)
194
+
195
+ when /^\+(?!\+)/
196
+ Termline::Style.colorize(" #{Termline::Style.icon(:add)}+#{msg}", :green)
197
+
198
+ # 3. Boolean/Nil Failures
199
+ # Covers cases like:
200
+ # Expected true to be nil
201
+ # Expected false to be truthy
202
+ # Expected "abc" to be empty
203
+ when /Expected (.*) to be (nil|truthy|falsey)/, /Expected (.*) to be (.*)/
204
+ Termline::Style.colorize(" #{Termline::Style.icon(:info)} #{msg}", :skyblue)
205
+
206
+ # 4. Standard Expected vs Actual Output
207
+ # Covers simple assertion output like:
208
+ # Expected: 1
209
+ # Actual: 2
210
+ when /^Expected:?\s+/
211
+ Termline::Style.colorize(" #{Termline::Style.icon(:add)} #{msg}", :green)
212
+
213
+ when /^Actual:?\s+/
214
+ Termline::Style.colorize(" #{Termline::Style.icon(:remove)} #{msg}", :red)
215
+
216
+ # 5. Rails Difference Failures
217
+ # Covers assertions like:
218
+ # "User.count" didn't change by 1
219
+ # actual change was 0
220
+ when /"(.*)" didn't change by (.*)/, /actual change was (.*)/
221
+ Termline::Style.colorize(" #{Termline::Style.icon(:warning)} #{msg}", :yellow)
222
+
223
+ # 6. Collection/Count Failures
224
+ # Covers collection assertions like:
225
+ # Expected 5 elements, found 2
226
+ # Expected exactly 1 nodes
227
+ when /Expected (.*) elements?, found (.*)/, /Expected exactly (.*) nodes/
228
+ Termline::Style.colorize(" #{Termline::Style.icon(:list)} #{msg}", :magenta)
229
+
230
+ # 7. Fallback for Custom or Unrecognized Messages
231
+ # Covers anything else not matched above.
232
+ else
233
+ Termline::Style.colorize(" #{Termline::Style.icon(:arrow_right)} #{msg}", :gray)
234
+ end
235
+ end.join("\n")
174
236
  end
175
237
  end
176
238
  end
@@ -0,0 +1,45 @@
1
+ =begin
2
+
3
+ Lesli
4
+
5
+ Copyright (c) 2026, Lesli Technologies, S. A.
6
+
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see http://www.gnu.org/licenses/.
19
+
20
+ Lesli · Ruby on Rails SaaS Development Framework.
21
+
22
+ Made with ♥ by LesliTech
23
+ Building a better future, one line of code at a time.
24
+
25
+ @contact hello@lesli.tech
26
+ @website https://www.lesli.tech
27
+ @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
+
29
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
+ // ·
31
+ =end
32
+
33
+ SimpleCov.profiles.define "lesli_rails_app" do
34
+ load_profile "rails"
35
+ track_files "{app,lib,engines,gems}/**/*.rb"
36
+ end
37
+
38
+ SimpleCov.profiles.define "lesli_rails_engine" do
39
+ load_profile "rails"
40
+ add_filter %r{^/test/}
41
+ end
42
+
43
+ SimpleCov.profiles.define "lesli_rails_gem" do
44
+ load_profile "rails"
45
+ end
@@ -37,24 +37,29 @@ require_relative "helpers/response_integration_helper"
37
37
  #
38
38
  module LesliTesting
39
39
 
40
- class IntegrationTester < ActionDispatch::IntegrationTest
41
- include ResponseIntegrationHelper
40
+ if defined?(ActionDispatch::IntegrationTest)
41
+ class IntegrationTester < ActionDispatch::IntegrationTest
42
+ include ResponseIntegrationHelper
43
+ end
42
44
  end
43
45
 
44
- class ViewTester < ActionView::TestCase
45
- # We use a hook to include the helpers only when the class is used.
46
- # This ensures Lesli core is fully loaded by Rails before we ask for the helpers.
47
- def self.inherited(subclass)
48
- super
49
- subclass.class_eval do
50
- include Lesli::HtmlHelper if defined?(Lesli::HtmlHelper)
51
- include Lesli::SystemHelper if defined?(Lesli::SystemHelper)
46
+ if defined?(ActionView::TestCase)
47
+ class ViewTester < ActionView::TestCase
48
+ # We use a hook to include the helpers only when the class is used.
49
+ # This ensures Lesli core is fully loaded by Rails before we ask for the helpers.
50
+ def self.inherited(subclass)
51
+ super
52
+ subclass.class_eval do
53
+ include Lesli::HtmlHelper if defined?(Lesli::HtmlHelper)
54
+ include Lesli::SystemHelper if defined?(Lesli::SystemHelper)
55
+ end
52
56
  end
53
57
  end
54
58
  end
55
59
 
56
- # Define the base classes inside the namespace
57
- class ModelTester < ActiveSupport::TestCase
58
- include ActiveSupport::Testing::TimeHelpers
60
+ if defined?(ActiveSupport::TestCase)
61
+ class ModelTester < ActiveSupport::TestCase
62
+ include ActiveSupport::Testing::TimeHelpers
63
+ end
59
64
  end
60
65
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LesliTesting
4
- VERSION = "1.2.3"
5
- BUILD = "1775000800"
4
+ VERSION = "1.3.0"
5
+ BUILD = "1775525290"
6
6
  end
data/lib/lesli_testing.rb CHANGED
@@ -1,37 +1,126 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Lesli
4
- #
5
- # Copyright (c) 2025, Lesli Technologies, S. A.
6
- #
7
- # This program is free software: you can redistribute it and/or modify
8
- # it under the terms of the GNU General Public License as published by
9
- # the Free Software Foundation, either version 3 of the License, or
10
- # (at your option) any later version.
11
- #
12
- # This program is distributed in the hope that it will be useful,
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- # GNU General Public License for more details.
16
- #
17
- # You should have received a copy of the GNU General Public License
18
- # along with this program. If not, see http://www.gnu.org/licenses/.
19
- #
20
- # Lesli · Ruby on Rails SaaS Development Framework.
21
- #
22
- # Made with by LesliTech
23
- # Building a better future, one line of code at a time.
24
- #
25
- # @contact hello@lesli.tech
26
- # @website https://www.lesli.tech
27
- # @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
- #
29
- # // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
- # // ·
31
-
32
- #
3
+ =begin
4
+
5
+ Lesli
6
+
7
+ Copyright (c) 2026, Lesli Technologies, S. A.
8
+
9
+ This program is free software: you can redistribute it and/or modify
10
+ it under the terms of the GNU General Public License as published by
11
+ the Free Software Foundation, either version 3 of the License, or
12
+ (at your option) any later version.
13
+
14
+ This program is distributed in the hope that it will be useful,
15
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ GNU General Public License for more details.
18
+
19
+ You should have received a copy of the GNU General Public License
20
+ along with this program. If not, see http://www.gnu.org/licenses/.
21
+
22
+ Lesli · Ruby on Rails SaaS Development Framework.
23
+
24
+ Made with ♥ by LesliTech
25
+ Building a better future, one line of code at a time.
26
+
27
+ @contact hello@lesli.tech
28
+ @website https://www.lesli.tech
29
+ @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
30
+
31
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
32
+ // ·
33
+ =end
34
+
35
+
33
36
  require_relative "lesli_testing/version"
34
- require "termline" unless defined?(Termline)
37
+
35
38
 
36
39
  module LesliTesting
40
+ class Error < StandardError; end
41
+
42
+ class << self
43
+
44
+ attr_accessor :app_module;
45
+ attr_accessor :app_name;
46
+ attr_writer :options
47
+
48
+ def app(name, options = {})
49
+ configure(name, options.merge(coverage_profile: "app"))
50
+ end
51
+
52
+ def engine(name, options = {})
53
+ configure(name, options.merge(coverage_profile: "engine"))
54
+ end
55
+
56
+ def gem(name, options = {})
57
+ configure(name, options.merge(coverage_profile: "gem"))
58
+ end
59
+
60
+ private
61
+
62
+ def options
63
+ @options ||= options_default
64
+ end
65
+
66
+ def options_default
67
+ {
68
+ coverage_profile: "app",
69
+ coverage_missing_len: 25,
70
+ coverage_min_coverage: 90
71
+ }
72
+ end
73
+
74
+ def configure(name, options)
75
+ self.app_name = name
76
+ self.options = options_default.merge(options)
77
+ configure_gems()
78
+ configure_reporter()
79
+ configure_coverage()
80
+ configure_fixtures()
81
+ end
82
+
83
+ def configure_coverage()
84
+
85
+ return unless ENV["COVERAGE"]
86
+ return if defined?(SimpleCov) && SimpleCov.running
87
+
88
+ # Start Coverage
89
+ LesliTesting::Coverage.start(
90
+ self.app_name,
91
+ profile: self.options[:coverage_profile],
92
+ missing_len: self.options[:coverage_missing_len],
93
+ min_coverage: self.options[:coverage_min_coverage]
94
+ )
95
+ end
96
+
97
+ # Load test configuration and test helper modules
98
+ def configure_fixtures()
99
+ LesliTesting::Fixtures.load_fixtures_for_lesli()
100
+ end
101
+
102
+ def configure_reporter
103
+ # Force Minitest to know about Lesli Minitest reporter plugin
104
+ unless Minitest.extensions.include?("lesli_testing")
105
+ Minitest.register_plugin("lesli_testing")
106
+ end
107
+ end
108
+
109
+ def configure_gems
110
+ return if @tools_loaded
111
+
112
+ #require "minitest"
113
+
114
+ # Load minitest plugin
115
+ require "minitest/lesli_testing_plugin"
116
+ require "termline" unless defined?(Termline)
117
+
118
+ # Load helper files
119
+ require_relative "lesli_testing/testers"
120
+ require_relative "lesli_testing/fixtures"
121
+ require_relative "lesli_testing/coverage"
122
+
123
+ @tools_loaded = true
124
+ end
125
+ end
37
126
  end
@@ -1,11 +1,12 @@
1
- require "lesli_testing/reporters/cli_reporter"
1
+ # Loading Lesli custom reporter for minitest
2
+ require "lesli_testing/minitest/cli_reporter"
2
3
 
3
4
  module Minitest
4
- def self.plugin_lesli_testing_options(opts, options)
5
- end
5
+ def self.plugin_lesli_testing_options(opts, options)
6
+ end
6
7
 
7
- def self.plugin_lesli_testing_init(options)
8
- reporter.reporters.clear if reporter.respond_to?(:reporters)
9
- reporter << LesliTesting::Reporters::CliReporter.new($stdout, options)
10
- end
8
+ def self.plugin_lesli_testing_init(options)
9
+ reporter.reporters.clear if reporter.respond_to?(:reporters)
10
+ reporter << LesliTesting::Reporters::CliReporter.new($stdout, options)
11
+ end
11
12
  end
data/readme.md CHANGED
@@ -10,11 +10,86 @@
10
10
 
11
11
  ### Quick start
12
12
 
13
+ <br />
14
+
15
+
16
+ **Install LesliTesting gem**
17
+
13
18
  ```shell
14
- # Add LesliAdmin engine gem
15
19
  bundle add lesli_testing
16
20
  ```
17
21
 
22
+ <br />
23
+
24
+ **Include LesliTesting in your test_helper.rb file**
25
+
26
+ ```ruby
27
+ ENV["RAILS_ENV"] ||= "test"
28
+
29
+
30
+ # Load LesliTesting tools
31
+ require "lesli_testing"
32
+
33
+
34
+ # Configure leslitesting tools for a rails engine
35
+ LesliTesting.engine("LesliShield")
36
+
37
+
38
+ # Configure lesli testing tools for a rails app
39
+ LesliTesting.app("LesliBuilder")
40
+
41
+
42
+ # # Configure leslitesting tools for a ruby gem
43
+ LesliTesting.gem("LesliDate")
44
+ ```
45
+
46
+ <br />
47
+
48
+ **Run your tests D:**
49
+
50
+ ```shell
51
+ rails test
52
+
53
+ # or
54
+
55
+ COVERAGE=true rails test
56
+
57
+ # or run like github actions
58
+
59
+ COVERAGE=true CI=true rails test
60
+ ```
61
+
62
+ <br />
63
+
64
+ **Result :D**
65
+
66
+ <div align="center">
67
+ <img
68
+ style="width:100%;max-width:800px;border-radius:6px;"
69
+ alt="LesliTesting screenshot" src="./docs/images/screenshot.png" />
70
+ </div>
71
+
72
+ <br />
73
+
74
+ ### Options
75
+
76
+ The following options can be used to customize coverage behavior in `LesliTesting`.
77
+
78
+ | Option | Type | Default | Description |
79
+ | ----------------------- | ------- | ------: | ------------------------------------------ |
80
+ | `coverage_missing_len` | Integer | `25` | Minimum width for missing coverage output. |
81
+ | `coverage_min_coverage` | Integer | `40` | Minimum expected coverage percentage. |
82
+
83
+ **Example:**
84
+
85
+ ```ruby
86
+ LesliTesting.configure(LesliShield, {
87
+ coverage_missing_len: 30,
88
+ coverage_min_coverage: 80
89
+ })
90
+ ```
91
+
92
+ <br />
18
93
 
19
94
  ### Documentation
20
95
  * [website](https://www.lesli.dev/)
@@ -27,6 +102,7 @@ bundle add lesli_testing
27
102
  * [Email: hello@lesli.tech](hello@lesli.tech)
28
103
  * [Website: https://www.lesli.tech](https://www.lesli.tech)
29
104
 
105
+ <br />
30
106
 
31
107
  ### License
32
108
  -------
@@ -45,17 +121,15 @@ GNU General Public License for more details.
45
121
  You should have received a copy of the GNU General Public License
46
122
  along with this program. If not, see http://www.gnu.org/licenses/.
47
123
 
48
- <br />
49
124
  <hr />
50
125
  <br />
51
126
  <br />
52
127
 
53
128
  <div align="center" class="has-text-centered">
54
- <img width="200" alt="Lesli logo" src="https://cdn.lesli.tech/lesli/brand/app-logo.svg" />
55
- <h3 align="center" class="mt-0">
129
+ <img width="80" alt="Lesli logo" src="https://cdn.lesli.tech/lesli/brand/app-icon.svg" />
130
+ <h4 align="center" class="mt-0">
56
131
  The Open-Source SaaS Development Framework for Ruby on Rails.
57
- </h3>
132
+ </h4>
58
133
  </div>
59
134
 
60
135
  <br />
61
- <br />
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lesli_testing
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Lesli Development Team
@@ -117,12 +117,12 @@ extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
119
  - lib/lesli_testing.rb
120
- - lib/lesli_testing/config.rb
121
120
  - lib/lesli_testing/coverage.rb
122
121
  - lib/lesli_testing/engine.rb
122
+ - lib/lesli_testing/fixtures.rb
123
123
  - lib/lesli_testing/helpers/response_integration_helper.rb
124
- - lib/lesli_testing/loader.rb
125
- - lib/lesli_testing/reporters/cli_reporter.rb
124
+ - lib/lesli_testing/minitest/cli_reporter.rb
125
+ - lib/lesli_testing/simplecov/profiles.rb
126
126
  - lib/lesli_testing/testers.rb
127
127
  - lib/lesli_testing/version.rb
128
128
  - lib/minitest/lesli_testing_plugin.rb
@@ -1,59 +0,0 @@
1
- =begin
2
-
3
- Lesli
4
-
5
- Copyright (c) 2026, Lesli Technologies, S. A.
6
-
7
- This program is free software: you can redistribute it and/or modify
8
- it under the terms of the GNU General Public License as published by
9
- the Free Software Foundation, either version 3 of the License, or
10
- (at your option) any later version.
11
-
12
- This program is distributed in the hope that it will be useful,
13
- but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- GNU General Public License for more details.
16
-
17
- You should have received a copy of the GNU General Public License
18
- along with this program. If not, see http://www.gnu.org/licenses/.
19
-
20
- Lesli · Ruby on Rails SaaS Development Framework.
21
-
22
- Made with ♥ by LesliTech
23
- Building a better future, one line of code at a time.
24
-
25
- @contact hello@lesli.tech
26
- @website https://www.lesli.tech
27
- @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
-
29
- // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
- // ·
31
- =end
32
-
33
- module LesliTesting
34
- module Config
35
- def self.apply(engine_module = nil)
36
-
37
- # Load dummy app for unit testing
38
- # Run tests across all the engines: LESLI_INTEGRATION_TEST=true rails test
39
- # Run tests for the current engine: rails test
40
- if engine_module
41
-
42
- # Load fixtures from the engine
43
- if ActiveSupport::TestCase.respond_to?(:fixture_paths=)
44
- ActiveSupport::TestCase.fixture_paths = [ engine_module.root.join("test", "fixtures").to_s ]
45
- ActionDispatch::IntegrationTest.fixture_paths = ActiveSupport::TestCase.fixture_paths
46
- ActiveSupport::TestCase.file_fixture_path = engine_module.root.join("test", "fixtures", "files").to_s
47
-
48
- # IMPORTANT: attach fixture sets to namespaced models BEFORE loading fixtures
49
- ActiveSupport::TestCase.set_fixture_class(
50
- lesli_users: "Lesli::User",
51
- lesli_accounts: "Lesli::Account"
52
- )
53
-
54
- ActiveSupport::TestCase.fixtures :all
55
- end
56
- end
57
- end
58
- end
59
- end
@@ -1,76 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Lesli
4
- #
5
- # Copyright (c) 2025, Lesli Technologies, S. A.
6
- #
7
- # This program is free software: you can redistribute it and/or modify
8
- # it under the terms of the GNU General Public License as published by
9
- # the Free Software Foundation, either version 3 of the License, or
10
- # (at your option) any later version.
11
- #
12
- # This program is distributed in the hope that it will be useful,
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- # GNU General Public License for more details.
16
- #
17
- # You should have received a copy of the GNU General Public License
18
- # along with this program. If not, see http://www.gnu.org/licenses/.
19
- #
20
- # Lesli · Ruby on Rails SaaS Development Framework.
21
- #
22
- # Made with ♥ by LesliTech
23
- # Building a better future, one line of code at a time.
24
- #
25
- # @contact hello@lesli.tech
26
- # @website https://www.lesli.tech
27
- # @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
- #
29
- # // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
- # // ·
31
-
32
-
33
- # Load code coverage tools
34
- require "simplecov"
35
- require "simplecov-console"
36
- require "simplecov-cobertura"
37
-
38
-
39
- # Load test frameworks
40
- require "minitest/lesli_testing_plugin"
41
- require_relative "reporters/cli_reporter"
42
-
43
- # Force Minitest to know about Lesli Minitest reporter plugin
44
- unless Minitest.extensions.include?("lesli_testing")
45
- Minitest.register_plugin("lesli_testing")
46
- end
47
-
48
- # Load test configuration and test helper modules
49
- require_relative "coverage"
50
- require_relative "testers"
51
- require_relative "config"
52
-
53
- module LesliTesting
54
- class Error < StandardError; end
55
-
56
- class << self
57
-
58
- attr_accessor :engine_module;
59
-
60
- def configure(engine_module = nil, options = {})
61
-
62
- engine_module = engine_module ? engine_module.name : "RailsApp"
63
-
64
- return if defined?(SimpleCov) && SimpleCov.running
65
-
66
- # Start Coverage
67
- LesliTesting::Coverage.start(engine_module, options[:min_coverage] || 40)
68
- end
69
-
70
- def configure_tests()
71
-
72
- # Apply Minitest/Reporters/Paths
73
- LesliTesting::Config.apply(engine_module)
74
- end
75
- end
76
- end