minitest-utils 0.4.8 → 0.4.9
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/README.md +34 -15
- data/lib/minitest/utils/extension.rb +5 -1
- data/lib/minitest/utils/rails.rb +4 -4
- data/lib/minitest/utils/reporter.rb +9 -0
- data/lib/minitest/utils/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef86ff4b6bec9c5eb30160fc0ca4bfe7b199a2bc7c25ab58130e5d98a37bcd3f
|
4
|
+
data.tar.gz: b7adae97b3be8e392f6975d8194d49762efea60635df6943a03d0a735e9d08c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d904701e8d64a581ec414f01de58ce9a4f1e00bb4bf4b71213f4259c9edca71b84ea2182171d827f75819e88e49ebdfab8062c56d82919eca336394ff46447fb
|
7
|
+
data.tar.gz: e2f4a293e89dc7e725afd67c3ae2154783c4ed3cd3ff6d48de60c037f5e14a6bc13583e8176fcb06f3b08661241a7b70c5cced430b3382f1f5797845d42c353c
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ Includes:
|
|
6
6
|
|
7
7
|
- A better reporter (see screenshot below)
|
8
8
|
- A [TestNotifier](http://github.com/fnando/test_notifier) reporter
|
9
|
-
- Some Rails niceties (set up
|
9
|
+
- Some Rails niceties (set up FactoryBot, WebMock and Capybara)
|
10
10
|
- Add a `t` and `l` methods (i18n)
|
11
11
|
|
12
12
|
## Installation
|
@@ -27,7 +27,8 @@ Or install it yourself as:
|
|
27
27
|
|
28
28
|
## Defining tests
|
29
29
|
|
30
|
-
This gem adds the `Minitest::Test.test` method, so you can easy define your
|
30
|
+
This gem adds the `Minitest::Test.test` method, so you can easy define your
|
31
|
+
methods like the following:
|
31
32
|
|
32
33
|
```ruby
|
33
34
|
class SampleTest < Minitest::Test
|
@@ -37,7 +38,10 @@ class SampleTest < Minitest::Test
|
|
37
38
|
end
|
38
39
|
```
|
39
40
|
|
40
|
-
This is equivalent to defining a method named `test_useless_test`. You can also
|
41
|
+
This is equivalent to defining a method named `test_useless_test`. You can also
|
42
|
+
skip the block, which will define a
|
43
|
+
[flunk](https://github.com/seattlerb/minitest/blob/77120c5b2511c4665610cda06c8058c801b28e7f/lib/minitest/assertions.rb#L477-L480)
|
44
|
+
call.
|
41
45
|
|
42
46
|
You can also define `setup` and `teardown` steps.
|
43
47
|
|
@@ -71,20 +75,30 @@ end
|
|
71
75
|
|
72
76
|
## Screenshots
|
73
77
|
|
74
|
-

|
79
|
+

|
80
|
+

|
81
|
+

|
78
82
|
|
79
83
|
## Rails extensions
|
80
84
|
|
81
85
|
minitest-utils sets up some things for your Rails application.
|
82
86
|
|
83
|
-
- [Capybara](https://github.com/jnicklas/capybara): includes `Capybara::DSL`,
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
87
|
+
- [Capybara](https://github.com/jnicklas/capybara): includes `Capybara::DSL`,
|
88
|
+
sets default driver before every test, resets session and creates a helper
|
89
|
+
method for setting JavaScript driver. If you have
|
90
|
+
[poltergeist](https://github.com/teampoltergeist/poltergeist) installed, it
|
91
|
+
will be used as the default JavaScript driver.
|
92
|
+
- [FactoryBot](https://github.com/thoughtbot/factory_bot): adds methods to
|
93
|
+
`ActiveSupport::TestCase`.
|
94
|
+
- [WebMock](https://github.com/bblimke/webmock): disables external requests
|
95
|
+
(except for codeclimate) and tracks all requests on `WebMock.requests`.
|
96
|
+
- locale routes: sets `Rails.application.routes.default_url_options[:locale]`
|
97
|
+
with your current locale.
|
98
|
+
- [DatabaseCleaner](https://github.com/DatabaseCleaner/database_cleaner):
|
99
|
+
configure database before running each test. You can configure the strategy by
|
100
|
+
settings `DatabaseCleaner.strategy = :truncation`, for instance. It defaults
|
101
|
+
to `:deletion`.
|
88
102
|
- Other: `t` and `l` alias to I18n.
|
89
103
|
|
90
104
|
```ruby
|
@@ -93,7 +107,8 @@ class SignupTest < ActionDispatch::IntegrationTtest
|
|
93
107
|
end
|
94
108
|
```
|
95
109
|
|
96
|
-
Also, if you're using routes like `:locale` scope, you can load this file to
|
110
|
+
Also, if you're using routes like `:locale` scope, you can load this file to
|
111
|
+
automatically set your route's `:locale` param.
|
97
112
|
|
98
113
|
```ruby
|
99
114
|
require 'minitest/utils/rails/locale'
|
@@ -101,9 +116,13 @@ require 'minitest/utils/rails/locale'
|
|
101
116
|
|
102
117
|
## Development
|
103
118
|
|
104
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
119
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
120
|
+
`bin/console` for an interactive prompt that will allow you to experiment.
|
105
121
|
|
106
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To
|
122
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To
|
123
|
+
release a new version, update the version number in `version.rb`, and then run
|
124
|
+
`bundle exec rake release` to create a git tag for the version, push git commits
|
125
|
+
and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
107
126
|
|
108
127
|
## Contributing
|
109
128
|
|
@@ -19,7 +19,11 @@ module Minitest
|
|
19
19
|
include ::Minitest::Utils::Assertions
|
20
20
|
|
21
21
|
def self.test(name, &block)
|
22
|
-
|
22
|
+
name = name.gsub(/[^a-z0-9]+/, "_")
|
23
|
+
.gsub(/^_+/, "")
|
24
|
+
.gsub(/_+$/, "")
|
25
|
+
.gsub(/_+/, "_")
|
26
|
+
test_name = "test_#{name}".to_sym
|
23
27
|
defined = method_defined? test_name
|
24
28
|
|
25
29
|
raise "#{test_name} is already defined in #{self}" if defined
|
data/lib/minitest/utils/rails.rb
CHANGED
@@ -23,12 +23,12 @@ module ActiveSupport
|
|
23
23
|
|
24
24
|
require "minitest/utils/rails/capybara" if defined?(Capybara)
|
25
25
|
|
26
|
-
def t(*args)
|
27
|
-
I18n.t(*args)
|
26
|
+
def t(*args, **kwargs)
|
27
|
+
I18n.t(*args, **kwargs)
|
28
28
|
end
|
29
29
|
|
30
|
-
def l(*args)
|
31
|
-
I18n.l(*args)
|
30
|
+
def l(*args, **kwargs)
|
31
|
+
I18n.l(*args, **kwargs)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -207,6 +207,15 @@ module Minitest
|
|
207
207
|
end
|
208
208
|
|
209
209
|
private def build_test_command(location, line, result)
|
210
|
+
if ENV["MINITEST_TEST_COMMAND"]
|
211
|
+
return format(
|
212
|
+
ENV["MINITEST_TEST_COMMAND"],
|
213
|
+
location: location,
|
214
|
+
line: line,
|
215
|
+
name: result.name
|
216
|
+
)
|
217
|
+
end
|
218
|
+
|
210
219
|
if running_rails?
|
211
220
|
%[bin/rails test #{location}:#{line}]
|
212
221
|
else
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-02-14 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: minitest
|
@@ -149,7 +148,6 @@ files:
|
|
149
148
|
homepage: http://github.com/fnando/minitest-utils
|
150
149
|
licenses: []
|
151
150
|
metadata: {}
|
152
|
-
post_install_message:
|
153
151
|
rdoc_options: []
|
154
152
|
require_paths:
|
155
153
|
- lib
|
@@ -164,8 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
162
|
- !ruby/object:Gem::Version
|
165
163
|
version: '0'
|
166
164
|
requirements: []
|
167
|
-
rubygems_version: 3.
|
168
|
-
signing_key:
|
165
|
+
rubygems_version: 3.6.2
|
169
166
|
specification_version: 4
|
170
167
|
summary: Some utilities for your Minitest day-to-day usage.
|
171
168
|
test_files: []
|