minitest-spec-rails 5.1.1 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/Appraisals +1 -1
- data/CHANGELOG.md +14 -0
- data/README.md +12 -4
- data/lib/minitest-spec-rails/init/active_job.rb +27 -0
- data/lib/minitest-spec-rails/railtie.rb +3 -0
- data/lib/minitest-spec-rails/version.rb +1 -1
- data/test/cases/active_job_test.rb +42 -0
- data/test/dummy_app/init.rb +2 -1
- data/test/dummy_tests/user_mailer_test.rb +7 -2
- data/test/dummy_tests/users_helper_test.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9408e396ed2d699f0d7c87a2ff129b6c5f2054a
|
4
|
+
data.tar.gz: 495b7c539331c43354e2d652f74206bbaf8be340
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6113aadd99cccdd0f45345a9ed4877b88e5ffbd7d137b00c7c20f7c3cc63f5a262c627731a024cc20f424b9028cf5f61764c126c81b409a3c7d2b317bccd526
|
7
|
+
data.tar.gz: 5512028271386985bd24bccf781d65597252a5a84a66ad242b27fdaa666afba433d4d88ecb028cda8c0d56d9a1169ab3f26f669b19d68be6c565f7215c8c83c3
|
data/.travis.yml
CHANGED
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
|
2
|
+
## 5.2.0
|
3
|
+
|
4
|
+
* Added ActiveJob support. Fixes #59. Thanks @xpepermint.
|
5
|
+
|
6
|
+
## 5.1.1
|
7
|
+
|
8
|
+
* Fix an issue where `describe` method was removed. Fixes #55 & #50
|
9
|
+
[41a0f851](https://github.com/metaskills/minitest-spec-rails/commit/41a0f851c8a290f59feb1cb8b20759f0e2a9697a)
|
10
|
+
|
11
|
+
## 5.1.0
|
12
|
+
|
13
|
+
No release notes yet. PRs welcome!
|
14
|
+
|
1
15
|
## 5.0.4
|
2
16
|
|
3
17
|
* Fixed ActiveSupport's Declarative#test forwarded implementation. Fixed #46.
|
data/README.md
CHANGED
@@ -15,10 +15,15 @@ The minitest-spec-rails gem makes it easy to use the MiniTest::Spec DSL within y
|
|
15
15
|
Existing or new Rails applications that use the default Rails testing structure can simply drop in the minitest-spec-gem and start writing their tests in the new spec DSL. Since MiniTest::Spec is built on top of MiniTest::Unit, a replacement for Test::Unit, all of your existing tests will continue to work.
|
16
16
|
|
17
17
|
|
18
|
-
#### Rails 4.1
|
18
|
+
#### Rails 4.1 or 4.2, 5.x
|
19
19
|
|
20
|
-
Our master branch is tracking rails 4.1 and up.
|
20
|
+
Our master branch is tracking rails 4.1, 4.2 and hopefully up to 5.x active development.
|
21
21
|
|
22
|
+
```ruby
|
23
|
+
group :test do
|
24
|
+
gem 'minitest-spec-rails'
|
25
|
+
end
|
26
|
+
```
|
22
27
|
|
23
28
|
#### For Rails 3.x or 4.0
|
24
29
|
|
@@ -26,7 +31,7 @@ Our [3-x-stable](https://github.com/metaskills/minitest-spec-rails/tree/3-x-stab
|
|
26
31
|
|
27
32
|
```ruby
|
28
33
|
group :test do
|
29
|
-
gem 'minitest-spec-rails'
|
34
|
+
gem 'minitest-spec-rails', '~> 4.7'
|
30
35
|
end
|
31
36
|
```
|
32
37
|
|
@@ -95,12 +100,14 @@ end
|
|
95
100
|
```ruby
|
96
101
|
require 'test_helper'
|
97
102
|
describe User do
|
98
|
-
# This will work too
|
103
|
+
# This will work too, but is not recommended
|
99
104
|
end
|
100
105
|
```
|
101
106
|
|
102
107
|
Just for reference, here is a full list of each of Rails test case classes and the matching describe alternative if one exists. Remember, names are important when using the describe syntax. So, you can not have a mailer named `FooBar` and expect it to work with the outer describe spec style since there is no way to map the spec type based on an existing naming convention.
|
103
108
|
|
109
|
+
Using `describe` in this way [is not recommended](https://github.com/metaskills/minitest-spec-rails/issues/56).
|
110
|
+
|
104
111
|
```ruby
|
105
112
|
# Model Test (or anything else not listed below)
|
106
113
|
class UserTest < ActiveSupport::TestCase
|
@@ -288,3 +295,4 @@ We have a few branches for each major Rails version.
|
|
288
295
|
Our current build status is:
|
289
296
|
[![Build Status](https://secure.travis-ci.org/metaskills/minitest-spec-rails.png)](http://travis-ci.org/metaskills/minitest-spec-rails)
|
290
297
|
|
298
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module MiniTestSpecRails
|
2
|
+
module Init
|
3
|
+
module ActiveJobBehavior
|
4
|
+
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
register_spec_type(self) { |desc| Class === desc && desc < ActiveJob::Base }
|
9
|
+
register_spec_type(/Job( ?Test)?\z/, self)
|
10
|
+
register_spec_type(self) { |desc| Class === desc && desc < self }
|
11
|
+
extend Descriptions
|
12
|
+
end
|
13
|
+
|
14
|
+
module Descriptions
|
15
|
+
|
16
|
+
def described_class
|
17
|
+
determine_default_mailer(name)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
ActiveJob::TestCase.send :include, MiniTestSpecRails::Init::ActiveJobBehavior
|
27
|
+
|
@@ -14,6 +14,9 @@ module MiniTestSpecRails
|
|
14
14
|
ActiveSupport.on_load(:action_mailer) do
|
15
15
|
require 'minitest-spec-rails/init/action_mailer'
|
16
16
|
end
|
17
|
+
ActiveSupport.on_load(:active_job) do
|
18
|
+
require 'minitest-spec-rails/init/active_job'
|
19
|
+
end
|
17
20
|
end if Rails.env.test?
|
18
21
|
|
19
22
|
initializer 'minitest-spec-rails.action_view', :after => 'action_view.setup_action_pack', :group => :all do |app|
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class MyJob < ActiveJob::Base ; def perform(record) ; true ; end end
|
4
|
+
class TrashableCleanupJob < MyJob ; end
|
5
|
+
|
6
|
+
class ActiveJobTest < MiniTestSpecRails::TestCase
|
7
|
+
|
8
|
+
it 'matches spec type for class constants' do
|
9
|
+
assert_job MiniTest::Spec.spec_type(MyJob)
|
10
|
+
assert_job MiniTest::Spec.spec_type(TrashableCleanupJob)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'matches spec type for strings' do
|
14
|
+
assert_job MiniTest::Spec.spec_type("WidgetJob")
|
15
|
+
assert_job MiniTest::Spec.spec_type("WidgetJobTest")
|
16
|
+
assert_job MiniTest::Spec.spec_type("Widget Job Test")
|
17
|
+
# And is case sensitive
|
18
|
+
refute_job MiniTest::Spec.spec_type("widgetmailer")
|
19
|
+
refute_job MiniTest::Spec.spec_type("widgetmailertest")
|
20
|
+
refute_job MiniTest::Spec.spec_type("widget mailer test")
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'wont match spec type for non space characters' do
|
24
|
+
refute_job MiniTest::Spec.spec_type("Widget Job\tTest")
|
25
|
+
refute_job MiniTest::Spec.spec_type("Widget Job\rTest")
|
26
|
+
refute_job MiniTest::Spec.spec_type("Widget Job\nTest")
|
27
|
+
refute_job MiniTest::Spec.spec_type("Widget Job\fTest")
|
28
|
+
refute_job MiniTest::Spec.spec_type("Widget JobXTest")
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def assert_job(actual)
|
35
|
+
assert_equal ActiveJob::TestCase, actual
|
36
|
+
end
|
37
|
+
|
38
|
+
def refute_job(actual)
|
39
|
+
refute_equal ActiveJob::TestCase, actual
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
data/test/dummy_app/init.rb
CHANGED
@@ -10,8 +10,9 @@ module Dummy
|
|
10
10
|
# Basic Engine
|
11
11
|
config.root = File.join __FILE__, '..'
|
12
12
|
config.cache_store = :memory_store
|
13
|
-
config.assets.enabled = false
|
13
|
+
config.assets.enabled = false
|
14
14
|
config.secret_token = '012345678901234567890123456789'
|
15
|
+
config.active_support.test_order = :random
|
15
16
|
|
16
17
|
# Mimic Test Environment Config.
|
17
18
|
config.whiny_nils = true if Rails.version < '4.0'
|
@@ -6,7 +6,12 @@ module UserMailerTests
|
|
6
6
|
|
7
7
|
let(:deliveries) { ActionMailer::Base.deliveries }
|
8
8
|
let(:user_mailer_class) { UserMailer }
|
9
|
-
let(:user_email) {
|
9
|
+
let(:user_email) {
|
10
|
+
user_mailer_class.welcome(user_ken).tap do |mail|
|
11
|
+
laterable = Rails.version > '4.2' || Rails.version.starts_with?('4.2')
|
12
|
+
laterable ? mail.deliver_now : mail.deliver
|
13
|
+
end
|
14
|
+
}
|
10
15
|
|
11
16
|
it 'works' do
|
12
17
|
deliveries.must_be :empty?
|
@@ -40,7 +45,7 @@ module UserMailerTests
|
|
40
45
|
end
|
41
46
|
|
42
47
|
end
|
43
|
-
|
48
|
+
|
44
49
|
end
|
45
50
|
end
|
46
51
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-spec-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ken Collins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- lib/minitest-spec-rails/init/action_dispatch.rb
|
103
103
|
- lib/minitest-spec-rails/init/action_mailer.rb
|
104
104
|
- lib/minitest-spec-rails/init/action_view.rb
|
105
|
+
- lib/minitest-spec-rails/init/active_job.rb
|
105
106
|
- lib/minitest-spec-rails/init/active_support.rb
|
106
107
|
- lib/minitest-spec-rails/init/mini_shoulda.rb
|
107
108
|
- lib/minitest-spec-rails/railtie.rb
|
@@ -111,6 +112,7 @@ files:
|
|
111
112
|
- test/cases/action_dispatch_test.rb
|
112
113
|
- test/cases/action_mailer_test.rb
|
113
114
|
- test/cases/action_view_test.rb
|
115
|
+
- test/cases/active_job_test.rb
|
114
116
|
- test/cases/active_support_test.rb
|
115
117
|
- test/cases/mini_shoulda_test.rb
|
116
118
|
- test/dummy_app/app/controllers/application_controller.rb
|
@@ -167,6 +169,7 @@ test_files:
|
|
167
169
|
- test/cases/action_dispatch_test.rb
|
168
170
|
- test/cases/action_mailer_test.rb
|
169
171
|
- test/cases/action_view_test.rb
|
172
|
+
- test/cases/active_job_test.rb
|
170
173
|
- test/cases/active_support_test.rb
|
171
174
|
- test/cases/mini_shoulda_test.rb
|
172
175
|
- test/dummy_app/app/controllers/application_controller.rb
|