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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6c837b598195683ee055f9ac77715ddfb20512f
4
- data.tar.gz: e81d2580abb2f695a604b18d7e02fc76d4341a9e
3
+ metadata.gz: e9408e396ed2d699f0d7c87a2ff129b6c5f2054a
4
+ data.tar.gz: 495b7c539331c43354e2d652f74206bbaf8be340
5
5
  SHA512:
6
- metadata.gz: ed1ad767526ebd9cf1317b48b30bb7c745d88b1fd2d8d8902d58d26448e2d193e982cd501318bea6c74b72f4db5fbfb4c462d0921ec105c1479dcf2f1ced0df5
7
- data.tar.gz: 2d06e00852ec0c800b56862cb22c7a12ed5af7e017707c9830eabd86e7ae03a69bcc94eb3ffcacab53c9f4bcf1d56a724a56bc37e180e7bd04f21be237c04625
6
+ metadata.gz: a6113aadd99cccdd0f45345a9ed4877b88e5ffbd7d137b00c7c20f7c3cc63f5a262c627731a024cc20f424b9028cf5f61764c126c81b409a3c7d2b317bccd526
7
+ data.tar.gz: 5512028271386985bd24bccf781d65597252a5a84a66ad242b27fdaa666afba433d4d88ecb028cda8c0d56d9a1169ab3f26f669b19d68be6c565f7215c8c83c3
data/.travis.yml CHANGED
@@ -1,3 +1,5 @@
1
+ sudo: false
2
+ cache: bundler
1
3
  rvm:
2
4
  - 1.9.3
3
5
  - 2.0.0
data/Appraisals CHANGED
@@ -3,5 +3,5 @@ appraise 'rails41' do
3
3
  end
4
4
 
5
5
  appraise 'rails42' do
6
- gem 'rails', '4.2.0.beta1'
6
+ gem 'rails', '4.2.0.rc3'
7
7
  end
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|
@@ -1,3 +1,3 @@
1
1
  module MiniTestSpecRails
2
- VERSION = "5.1.1"
2
+ VERSION = "5.2.0"
3
3
  end
@@ -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
@@ -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 if Rails.version > '3.1'
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) { user_mailer_class.welcome(user_ken).deliver }
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
 
@@ -32,7 +32,7 @@ module UsersHelperTests
32
32
  end
33
33
 
34
34
  end
35
-
35
+
36
36
  end
37
37
  end
38
38
 
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.1.1
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: 2014-11-19 00:00:00.000000000 Z
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