packs-rails-minitest 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fddbb6805d5c9bc1eb4b26237aff41722680c169e654c466b9cf905ce6ba8200
4
- data.tar.gz: 3d4430613d07777760f988d00d8351d9218383cc90fdcef49c59a36baf07e566
3
+ metadata.gz: a008e4260ca748c748a4350604aad96ed530a72890fca8843f193ba88f7e4d08
4
+ data.tar.gz: 8dca0e3def66f6c5d4b7a5d426d935cf08c278126745b68a5a0bfcd8d01baf91
5
5
  SHA512:
6
- metadata.gz: 500e5a3f7a1e70339ff8c899041162f7bf7c77160a78dcf317c4b24eef5eea94d72e3f6c92d9665781c7919d6b99f99a1555543d21864f94921ca7f41aa48551
7
- data.tar.gz: 87d68c92d74fe476bebc9f528b4db187d41ec3cf6d3667f361fda2b987f01d07be5026a0576a80e02b40c4fa165617b8ce5c87651c298b006672b5d70e1a5096
6
+ metadata.gz: f49e7286ceb0fbe1e9b70bc4c64ef9d7722f8a478fb8e62f41c9e7e58afaa8f77e161f34311f1024bfa6d9e5cb5fe085eeb850d2ee3db34a9cb4fd73a7d4e38f
7
+ data.tar.gz: 6ef33ade79dfc77b3bdb9fb02d220611add3b78ebcc2fcb9f61adc5036b1951f98016d2bc860e4b571d6ad00fe1c393c0595649508f71378b70b4c4f8a1e052e
data/README.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  Adds Rake tasks for testing [packs](https://github.com/rubyatscale/packs) using minitest.
4
4
 
5
+ ## Installation
6
+
7
+ Add the gem to your `Gemfile`:
8
+
9
+ ```shell
10
+ bundle add packs-rails-minitest --group development,test
11
+ ```
12
+
5
13
  ## Usage
6
14
 
7
15
  Once installed, this gem provides the following Rake tasks:
@@ -18,17 +26,33 @@ For each pack, the following tasks are also added:
18
26
  - `packs:test:<pack name>:system` - runs all system tests in the pack
19
27
  - `packs:test:<pack name>:all` - runs all tests in the pack including system tests
20
28
 
21
- ## Installation
29
+ ### Overriding standard Rails test tasks
22
30
 
23
- Add this line to your application's Gemfile:
31
+ `rails test` and similar are defined using Thor, meaning they cannot be easily overridden by Rake tasks. There are two
32
+ ways to overcome this:
24
33
 
25
- ```ruby
26
- gem "packs-rails-minitest", group: :development
27
- ```
34
+ 1. Set the environment variables `DEFAULT_TEST` and `DEFAULT_TEST_EXCLUDE` to appropriate globs
35
+ 2. Create new Rake tasks and use `rake test` instead of `rails test` (recommended)
28
36
 
29
- And then execute:
30
- ```bash
31
- $ bundle
37
+ #### Setting environment variables
38
+
39
+ The environment variables should be set to values returned by the following Ruby code:
40
+
41
+ | Variable | Ruby |
42
+ |----------------------|--------------------------------------------------------------------------------------|
43
+ | DEFAULT_TEST | `"{.,#{Packs.all.map(&:relative_path).join(",")}/test/**/*_test.rb}"` |
44
+ | DEFAULT_TEST_EXCLUDE | `"{.,#{Packs.all.map(&:relative_path).join(",")}/test/{system,dummy}/**/*_test.rb}"` |
45
+
46
+ 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
47
+ sure you only set it if it is not already set, otherwise the Rake tasks defined in this package may not work.
48
+
49
+ #### Rake task
50
+
51
+ Appropriate Rake tasks will be defined for you by setting `config.packs_rails_minitest.override_tasks = true` in
52
+ your `application.rb`. If you only include this gem in specific environments you will need to set it conditionally e.g.
53
+
54
+ ```ruby
55
+ config.packs_rails_minitest.override_tasks = true if Rails.env.development? || Rails.env.test?
32
56
  ```
33
57
 
34
58
  ## Contributing
@@ -36,4 +60,5 @@ $ bundle
36
60
  Contributions are welcome, simply create a pull request or file an issue.
37
61
 
38
62
  ## License
63
+
39
64
  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.1"
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,25 @@ 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
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
+ system("rails", "test")
50
+ end
51
+
52
+ namespace :test do
53
+ multitask all: [:prepare, "packs:test:prepare"] do
54
+ system("rails", "test", "test/**/*_test.rb", *Packs.all.map { |pack| pack.relative_path.join("test/**/*_test.rb").to_s })
55
+ end
56
+
57
+ multitask system: [:prepare, "packs:test:prepare"] do
58
+ system("rails", "test", "test/system/**/*_test.rb", *Packs.all.map { |pack| pack.relative_path.join("test/system/**/*_test.rb").to_s })
59
+ end
60
+ end
61
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
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.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Graham Rogers
@@ -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