minitest-rails 2.1.1 → 2.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 +4 -3
- data/CHANGELOG.rdoc +9 -0
- data/Gemfile +1 -1
- data/Manifest.txt +8 -0
- data/Rakefile +1 -1
- data/gemfiles/4.2.gemfile +5 -0
- data/lib/generators/minitest/controller/templates/controller_spec.rb +1 -1
- data/lib/generators/minitest/helper/templates/helper_spec.rb +0 -2
- data/lib/generators/minitest/helper/templates/helper_test.rb +0 -2
- data/lib/generators/minitest/install/install_generator.rb +1 -6
- data/lib/generators/minitest/install/templates/test_helper.rb +2 -10
- data/lib/generators/minitest/job/job_generator.rb +19 -0
- data/lib/generators/minitest/job/templates/job_spec.rb +9 -0
- data/lib/generators/minitest/job/templates/job_test.rb +9 -0
- data/lib/generators/minitest/mailer/templates/mailer_spec.rb +4 -4
- data/lib/generators/minitest/model/templates/model_spec.rb +1 -1
- data/lib/generators/minitest/model/templates/model_test.rb +0 -2
- data/lib/generators/minitest/route/templates/route_spec.rb +5 -2
- data/lib/generators/minitest/route/templates/route_test.rb +4 -1
- data/lib/generators/minitest/scaffold/templates/controller_spec.rb +12 -14
- data/lib/generators/minitest/scaffold/templates/controller_test.rb +2 -3
- data/lib/minitest/rails.rb +16 -3
- data/lib/minitest/rails/assertions.rb +223 -1
- data/lib/minitest/rails/expectations.rb +205 -24
- data/lib/minitest/rails/version.rb +1 -1
- data/minitest-rails.gemspec +11 -12
- data/tasks/test.rake +9 -0
- data/test/generators/test_install_generator.rb +0 -6
- data/test/generators/test_job_generator.rb +45 -0
- data/test/helper.rb +12 -0
- data/test/rails/action_controller/test_expectations.rb +6 -5
- data/test/rails/active_job/test_assertions.rb +46 -0
- data/test/rails/active_job/test_expectations.rb +55 -0
- data/test/rails/active_job/test_spec_type.rb +49 -0
- data/test/rails/active_support/test_expectations.rb +4 -4
- metadata +14 -30
data/test/helper.rb
CHANGED
@@ -9,6 +9,11 @@ require "active_record"
|
|
9
9
|
require "action_controller"
|
10
10
|
require "action_controller/railtie"
|
11
11
|
|
12
|
+
begin
|
13
|
+
require "active_job"
|
14
|
+
rescue LoadError
|
15
|
+
end
|
16
|
+
|
12
17
|
require "action_mailer"
|
13
18
|
|
14
19
|
require "minitest-rails"
|
@@ -40,6 +45,7 @@ require "rails/test_help"
|
|
40
45
|
|
41
46
|
module TestApp
|
42
47
|
class Application < ::Rails::Application
|
48
|
+
config.active_support.test_order = :random
|
43
49
|
config.secret_key_base = "abc123"
|
44
50
|
end
|
45
51
|
end
|
@@ -64,3 +70,9 @@ TestApp::Application.routes.draw do
|
|
64
70
|
end
|
65
71
|
|
66
72
|
ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
|
73
|
+
|
74
|
+
if defined? ActiveJob
|
75
|
+
class UserInviteJob < ActiveJob::Base
|
76
|
+
def perform(arg = nil); end
|
77
|
+
end
|
78
|
+
end
|
@@ -6,6 +6,7 @@ class TestActionControllerExpectations < ActionController::TestCase
|
|
6
6
|
def test_must_respond_with
|
7
7
|
get :index
|
8
8
|
must_respond_with :success
|
9
|
+
value(response).must_be :success?
|
9
10
|
end
|
10
11
|
|
11
12
|
def test_must_redirect_to
|
@@ -21,9 +22,9 @@ class TestActionControllerExpectations < ActionController::TestCase
|
|
21
22
|
def test_routing_expectations
|
22
23
|
params = { :controller => "models", :action => "index" }
|
23
24
|
path = "/models"
|
24
|
-
params.must_route_to path
|
25
|
-
path.must_route_from params
|
26
|
-
params.must_route_for path
|
25
|
+
value(params).must_route_to path
|
26
|
+
value(path).must_route_from params
|
27
|
+
value(params).must_route_for path
|
27
28
|
end
|
28
29
|
|
29
30
|
def test_must_dom_equal
|
@@ -31,8 +32,8 @@ class TestActionControllerExpectations < ActionController::TestCase
|
|
31
32
|
apple_link2 = '<a target="_blank" href="http://www.example.com">Apples</a>'
|
32
33
|
orange_link = '<a href="http://www.example.com">Oranges</a>'
|
33
34
|
|
34
|
-
apple_link.must_dom_equal apple_link2
|
35
|
-
apple_link.wont_dom_equal orange_link
|
35
|
+
value(apple_link).must_dom_equal apple_link2
|
36
|
+
value(apple_link).wont_dom_equal orange_link
|
36
37
|
end
|
37
38
|
|
38
39
|
def test_must_select
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
if defined? ActiveJob # Rails 4.2 and later.
|
4
|
+
class TestActiveJobAssertions < ActiveJob::TestCase
|
5
|
+
def test_assert_enqueued_jobs
|
6
|
+
assert_enqueued_jobs 0
|
7
|
+
UserInviteJob.logger.silence { UserInviteJob.perform_later }
|
8
|
+
assert_enqueued_jobs 1
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_assert_no_enqueued_jobs
|
12
|
+
assert_no_enqueued_jobs
|
13
|
+
UserInviteJob.new
|
14
|
+
assert_no_enqueued_jobs
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_assert_performed_jobs
|
18
|
+
assert_performed_jobs 0
|
19
|
+
assert_performed_jobs 2 do
|
20
|
+
UserInviteJob.logger.silence do
|
21
|
+
UserInviteJob.perform_later
|
22
|
+
UserInviteJob.perform_later
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_assert_no_performed_jobs
|
28
|
+
assert_no_performed_jobs
|
29
|
+
assert_no_performed_jobs do
|
30
|
+
UserInviteJob.new
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_assert_enqueued_with
|
35
|
+
assert_enqueued_with job: UserInviteJob, args: [209] do
|
36
|
+
UserInviteJob.logger.silence { UserInviteJob.perform_later(209) }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_assert_performed_with
|
41
|
+
assert_performed_with job: UserInviteJob, args: [107] do
|
42
|
+
UserInviteJob.logger.silence { UserInviteJob.perform_later(107) }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
if defined? ActiveJob # Rails 4.2 and later.
|
4
|
+
module ActiveJobExpectationTests
|
5
|
+
def test_must_enqueue_jobs
|
6
|
+
must_enqueue_jobs 0
|
7
|
+
UserInviteJob.logger.silence { UserInviteJob.perform_later }
|
8
|
+
must_enqueue_jobs 1
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_wont_enqueue_jobs
|
12
|
+
wont_enqueue_jobs
|
13
|
+
UserInviteJob.new
|
14
|
+
wont_enqueue_jobs
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_must_perform_jobs
|
18
|
+
must_perform_jobs 0
|
19
|
+
must_perform_jobs 2 do
|
20
|
+
UserInviteJob.logger.silence do
|
21
|
+
UserInviteJob.perform_later
|
22
|
+
UserInviteJob.perform_later
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_wont_perform_jobs
|
28
|
+
wont_perform_jobs
|
29
|
+
wont_perform_jobs do
|
30
|
+
UserInviteJob.new
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_must_enqueue_with
|
35
|
+
must_enqueue_with job: UserInviteJob, args: [209] do
|
36
|
+
UserInviteJob.logger.silence { UserInviteJob.perform_later(209) }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_must_perform_with
|
41
|
+
must_perform_with job: UserInviteJob, args: [107] do
|
42
|
+
UserInviteJob.logger.silence { UserInviteJob.perform_later(107) }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class TestActiveJobExpectations < ActiveJob::TestCase
|
48
|
+
include ActiveJobExpectationTests
|
49
|
+
end
|
50
|
+
|
51
|
+
class TestActiveJobExpectationInCustomTestCase < ActiveSupport::TestCase
|
52
|
+
include Minitest::Rails::Expectations::ActiveJob
|
53
|
+
include ActiveJobExpectationTests
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
if defined? ActiveJob # Rails 4.2 and later.
|
4
|
+
class UserInviteJob < ActiveJob::Base; end
|
5
|
+
class InviteUser < ActiveJob::Base; end
|
6
|
+
|
7
|
+
class TestActiveJobSpecType < Minitest::Test
|
8
|
+
def assert_job actual
|
9
|
+
assert_equal ActiveJob::TestCase, actual
|
10
|
+
end
|
11
|
+
|
12
|
+
def refute_job actual
|
13
|
+
refute_equal ActiveJob::TestCase, actual
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_spec_type_resolves_for_class_constants
|
17
|
+
assert_job Minitest::Spec.spec_type(UserInviteJob)
|
18
|
+
assert_job Minitest::Spec.spec_type(InviteUser)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_spec_type_resolves_for_matching_string
|
22
|
+
assert_job Minitest::Spec.spec_type("UserInviteJob")
|
23
|
+
assert_job Minitest::Spec.spec_type("UserInviteJobTest")
|
24
|
+
assert_job Minitest::Spec.spec_type("User Invite Job Test")
|
25
|
+
# And is not case sensitive
|
26
|
+
assert_job Minitest::Spec.spec_type("userinvitejob")
|
27
|
+
assert_job Minitest::Spec.spec_type("userinvitejobtest")
|
28
|
+
assert_job Minitest::Spec.spec_type("user invite job test")
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_spec_type_wont_match_non_space_characters
|
32
|
+
refute_job Minitest::Spec.spec_type("User Invite Job\tTest")
|
33
|
+
refute_job Minitest::Spec.spec_type("User Invite Job\rTest")
|
34
|
+
refute_job Minitest::Spec.spec_type("User Invite Job\nTest")
|
35
|
+
refute_job Minitest::Spec.spec_type("User Invite Job\fTest")
|
36
|
+
refute_job Minitest::Spec.spec_type("User Invite JobXTest")
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_spec_type_doesnt_resolve_random_strings
|
40
|
+
refute_job Minitest::Spec.spec_type("Unmatched String")
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_spec_type_resolves_for_additional_desc_job
|
44
|
+
assert_job Minitest::Spec.spec_type("Unmatched String", :job)
|
45
|
+
assert_job Minitest::Spec.spec_type("Unmatched String", :job, :other)
|
46
|
+
assert_job Minitest::Spec.spec_type("Unmatched String", :other, :job)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -6,16 +6,16 @@ class TestActiveSupportExpectations < ActiveSupport::TestCase
|
|
6
6
|
def test_must_change
|
7
7
|
counter = 0
|
8
8
|
|
9
|
-
|
9
|
+
value { counter += 1 }.must_change "counter", +1
|
10
10
|
|
11
|
-
|
11
|
+
value { counter += 3 }.must_change "counter", +3
|
12
12
|
|
13
|
-
|
13
|
+
value { counter -= 1 }.must_change "counter", -1
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_wont_change
|
17
17
|
counter = 0
|
18
18
|
|
19
|
-
|
19
|
+
value { counter = 0 }.wont_change "counter"
|
20
20
|
end
|
21
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Moore
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '5.
|
19
|
+
version: '5.7'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '5.
|
26
|
+
version: '5.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: railties
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- README.rdoc
|
101
101
|
- Rakefile
|
102
102
|
- gemfiles/4.1.gemfile
|
103
|
+
- gemfiles/4.2.gemfile
|
103
104
|
- lib/generators/.document
|
104
105
|
- lib/generators/minitest.rb
|
105
106
|
- lib/generators/minitest/controller/controller_generator.rb
|
@@ -116,6 +117,9 @@ files:
|
|
116
117
|
- lib/generators/minitest/integration/integration_generator.rb
|
117
118
|
- lib/generators/minitest/integration/templates/integration_spec.rb
|
118
119
|
- lib/generators/minitest/integration/templates/integration_test.rb
|
120
|
+
- lib/generators/minitest/job/job_generator.rb
|
121
|
+
- lib/generators/minitest/job/templates/job_spec.rb
|
122
|
+
- lib/generators/minitest/job/templates/job_test.rb
|
119
123
|
- lib/generators/minitest/mailer/mailer_generator.rb
|
120
124
|
- lib/generators/minitest/mailer/templates/mailer_spec.rb
|
121
125
|
- lib/generators/minitest/mailer/templates/mailer_test.rb
|
@@ -143,6 +147,7 @@ files:
|
|
143
147
|
- test/generators/test_generator_generator.rb
|
144
148
|
- test/generators/test_helper_generator.rb
|
145
149
|
- test/generators/test_install_generator.rb
|
150
|
+
- test/generators/test_job_generator.rb
|
146
151
|
- test/generators/test_mailer_generator.rb
|
147
152
|
- test/generators/test_model_generator.rb
|
148
153
|
- test/generators/test_route_generator.rb
|
@@ -157,6 +162,9 @@ files:
|
|
157
162
|
- test/rails/action_mailer/test_spec_type.rb
|
158
163
|
- test/rails/action_view/test_helpers.rb
|
159
164
|
- test/rails/action_view/test_spec_type.rb
|
165
|
+
- test/rails/active_job/test_assertions.rb
|
166
|
+
- test/rails/active_job/test_expectations.rb
|
167
|
+
- test/rails/active_job/test_spec_type.rb
|
160
168
|
- test/rails/active_support/test_assertions.rb
|
161
169
|
- test/rails/active_support/test_expectations.rb
|
162
170
|
- test/rails/active_support/test_spec_type.rb
|
@@ -186,32 +194,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
194
|
version: '0'
|
187
195
|
requirements: []
|
188
196
|
rubyforge_project:
|
189
|
-
rubygems_version: 2.
|
197
|
+
rubygems_version: 2.4.6
|
190
198
|
signing_key:
|
191
199
|
specification_version: 4
|
192
200
|
summary: Minitest integration for Rails
|
193
|
-
test_files:
|
194
|
-
- test/generators/test_controller_generator.rb
|
195
|
-
- test/generators/test_generator_generator.rb
|
196
|
-
- test/generators/test_helper_generator.rb
|
197
|
-
- test/generators/test_install_generator.rb
|
198
|
-
- test/generators/test_mailer_generator.rb
|
199
|
-
- test/generators/test_model_generator.rb
|
200
|
-
- test/generators/test_route_generator.rb
|
201
|
-
- test/generators/test_scaffold_generator.rb
|
202
|
-
- test/rails/action_controller/test_assertions.rb
|
203
|
-
- test/rails/action_controller/test_controllers.rb
|
204
|
-
- test/rails/action_controller/test_expectations.rb
|
205
|
-
- test/rails/action_controller/test_spec_type.rb
|
206
|
-
- test/rails/action_dispatch/test_spec_type.rb
|
207
|
-
- test/rails/action_mailer/test_mailers.rb
|
208
|
-
- test/rails/action_mailer/test_spec_type.rb
|
209
|
-
- test/rails/action_view/test_helpers.rb
|
210
|
-
- test/rails/action_view/test_spec_type.rb
|
211
|
-
- test/rails/active_support/test_assertions.rb
|
212
|
-
- test/rails/active_support/test_expectations.rb
|
213
|
-
- test/rails/active_support/test_spec_type.rb
|
214
|
-
- test/rails/generators/test_spec_type.rb
|
215
|
-
- test/rails/test_constant_lookup.rb
|
216
|
-
- test/test_sanity.rb
|
217
|
-
- test/rails/minitest_5_api_test.rb
|
201
|
+
test_files: []
|