packs-rails-minitest 0.1.0 → 0.1.2

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: fddbb6805d5c9bc1eb4b26237aff41722680c169e654c466b9cf905ce6ba8200
4
- data.tar.gz: 3d4430613d07777760f988d00d8351d9218383cc90fdcef49c59a36baf07e566
3
+ metadata.gz: 33289367f34dd0f850b82b3a7630ed59a8d13baac106e2b0da5d937bd4be211b
4
+ data.tar.gz: 6ac5cc2a020bad866dd06e9b41f890a8172dab7b292be0251f6e04b1e6047751
5
5
  SHA512:
6
- metadata.gz: 500e5a3f7a1e70339ff8c899041162f7bf7c77160a78dcf317c4b24eef5eea94d72e3f6c92d9665781c7919d6b99f99a1555543d21864f94921ca7f41aa48551
7
- data.tar.gz: 87d68c92d74fe476bebc9f528b4db187d41ec3cf6d3667f361fda2b987f01d07be5026a0576a80e02b40c4fa165617b8ce5c87651c298b006672b5d70e1a5096
6
+ metadata.gz: a0ece2ad345375fbb1f03ae6665061d272973a2ba00b8659e14e66b4d1dac3d9f2f40cc9488cf6e12fd760d96cd496515b4f3d5003263265961244081f8d7d1d
7
+ data.tar.gz: 368bef89616a98172e4b97e4bdad018325d4c24712667b194a7792e21386ca1cb0d93a07e20fa5991d72e8c300f908b3cab7c4d12419195a51e83c8d1b1d89d5
data/README.md CHANGED
@@ -1,7 +1,17 @@
1
1
  # Packs::Rails::Minitest
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/packs-rails-minitest.svg)](https://badge.fury.io/rb/packs-rails-minitest)
4
+
3
5
  Adds Rake tasks for testing [packs](https://github.com/rubyatscale/packs) using minitest.
4
6
 
7
+ ## Installation
8
+
9
+ Add the gem to your `Gemfile`:
10
+
11
+ ```shell
12
+ bundle add packs-rails-minitest --group development,test
13
+ ```
14
+
5
15
  ## Usage
6
16
 
7
17
  Once installed, this gem provides the following Rake tasks:
@@ -18,22 +28,47 @@ For each pack, the following tasks are also added:
18
28
  - `packs:test:<pack name>:system` - runs all system tests in the pack
19
29
  - `packs:test:<pack name>:all` - runs all tests in the pack including system tests
20
30
 
21
- ## Installation
31
+ ### Overriding standard Rails test tasks
32
+
33
+ `rails test` and similar are defined using Thor, meaning they cannot be easily overridden by Rake tasks. There are two
34
+ ways to overcome this:
35
+
36
+ 1. Set the environment variables `DEFAULT_TEST` and `DEFAULT_TEST_EXCLUDE` to appropriate globs
37
+ 2. Create new Rake tasks and use `rake test` instead of `rails test` (recommended)
22
38
 
23
- Add this line to your application's Gemfile:
39
+ #### Setting environment variables
40
+
41
+ The environment variables should be set to values returned by the following Ruby code:
42
+
43
+ | Variable | Ruby |
44
+ |----------------------|--------------------------------------------------------------------------------------|
45
+ | DEFAULT_TEST | `"{.,#{Packs.all.map(&:relative_path).join(",")}}/test/**/*_test.rb"` |
46
+ | DEFAULT_TEST_EXCLUDE | `"{.,#{Packs.all.map(&:relative_path).join(",")}}/test/{system,dummy}/**/*_test.rb"` |
47
+
48
+ How you set this up is up to you, there isn't really a standard place. In `application.rb` or `boot.rb` work, just make
49
+ sure you only set it if it is not already set, otherwise the Rake tasks defined in this package may not work.
50
+
51
+ You'll also need to make sure the prepare tasks are run as part of `test:prepare`, e.g.:
24
52
 
25
53
  ```ruby
26
- gem "packs-rails-minitest", group: :development
54
+ Rake::Task["test:prepare"].enhance(["packs:test:prepare"])
27
55
  ```
28
56
 
29
- And then execute:
30
- ```bash
31
- $ bundle
57
+ #### Rake tasks
58
+
59
+ Appropriate Rake tasks will be defined for you by setting `config.packs_rails_minitest.override_tasks = true` in
60
+ your `application.rb`. If you only include this gem in specific environments you will need to set it conditionally e.g.
61
+
62
+ ```ruby
63
+ config.packs_rails_minitest.override_tasks = true if Rails.env.development? || Rails.env.test?
32
64
  ```
33
65
 
66
+ Remember that you must use `rake test` instead of `rails test` for this to work.
67
+
34
68
  ## Contributing
35
69
 
36
70
  Contributions are welcome, simply create a pull request or file an issue.
37
71
 
38
72
  ## License
73
+
39
74
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -1,9 +1,13 @@
1
+ require "active_support/ordered_options"
1
2
  require "rails/railtie"
2
3
 
3
4
  module Packs
4
5
  module Rails
5
6
  module Minitest
6
7
  class Railtie < ::Rails::Railtie
8
+ config.packs_rails_minitest = ::ActiveSupport::OrderedOptions.new
9
+ config.packs_rails_minitest.override_tasks = false
10
+
7
11
  rake_tasks do
8
12
  load "tasks/packs/test.rake"
9
13
  end
@@ -1,7 +1,7 @@
1
1
  module Packs
2
2
  module Rails
3
3
  module Minitest
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  namespace :packs do
2
2
  task test: "test:prepare" do
3
- ENV["DEFAULT_TEST"] = "{#{Packs.all.map(&:name).join(",")}}/test/**/*_test.rb"
4
- ENV["DEFAULT_TEST_EXCLUDE"] = "{#{Packs.all.map(&:name).join(",")}}/test/{system,dummy}/**/*_test.rb"
3
+ ENV["DEFAULT_TEST"] = "{#{Packs.all.map(&:relative_path).join(",")}}/test/**/*_test.rb"
4
+ ENV["DEFAULT_TEST_EXCLUDE"] = "{#{Packs.all.map(&:relative_path).join(",")}}/test/{system,dummy}/**/*_test.rb"
5
5
  system("rails", "test")
6
6
  end
7
7
 
@@ -37,3 +37,29 @@ namespace :packs do
37
37
  end
38
38
  end
39
39
  end
40
+
41
+ if Rails.configuration.packs_rails_minitest.override_tasks
42
+ Rake::Task["test"]&.clear
43
+ Rake::Task["test:all"]&.clear
44
+ Rake::Task["test:system"]&.clear
45
+
46
+ multitask test: ["test:prepare", "packs:test:prepare"] do |_, args|
47
+ ENV["DEFAULT_TEST"] = "{.,#{Packs.all.map(&:relative_path).join(",")}}/test/**/*_test.rb"
48
+ ENV["DEFAULT_TEST_EXCLUDE"] = "{.,#{Packs.all.map(&:relative_path).join(",")}}/test/{system,dummy}/**/*_test.rb"
49
+ if ENV.key? "TEST"
50
+ system("rails", "test", ENV["TEST"])
51
+ else
52
+ system("rails", "test")
53
+ end
54
+ end
55
+
56
+ namespace :test do
57
+ multitask all: [:prepare, "packs:test:prepare"] do |_, args|
58
+ system("rails", "test", "test/**/*_test.rb", *Packs.all.map { |pack| pack.relative_path.join("test/**/*_test.rb").to_s })
59
+ end
60
+
61
+ multitask system: [:prepare, "packs:test:prepare"] do |_, args|
62
+ system("rails", "test", "test/system/**/*_test.rb", *Packs.all.map { |pack| pack.relative_path.join("test/system/**/*_test.rb").to_s })
63
+ end
64
+ end
65
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: packs-rails-minitest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Graham Rogers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-20 00:00:00.000000000 Z
11
+ date: 2023-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: packs
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '7'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '7'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: railties
29
43
  requirement: !ruby/object:Gem::Requirement