minitest-rails 2.2.1 → 3.0.0.rc1
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/.travis.yml +8 -6
- data/CHANGELOG.rdoc +0 -6
- data/Gemfile +1 -1
- data/Manifest.txt +6 -13
- data/Rakefile +4 -3
- data/gemfiles/5.0.gemfile +5 -0
- data/gemfiles/head.gemfile +5 -0
- data/lib/generators/minitest/controller/templates/controller_spec.rb +9 -5
- data/lib/generators/minitest/controller/templates/controller_test.rb +9 -5
- data/lib/generators/minitest/generator/generator_generator.rb +2 -3
- data/lib/generators/minitest/generator/templates/generator_spec.rb +1 -1
- data/lib/generators/minitest/generator/templates/generator_test.rb +1 -1
- data/lib/generators/minitest/helper/helper_generator.rb +1 -11
- data/lib/generators/minitest/integration/integration_generator.rb +1 -2
- data/lib/generators/minitest/integration/templates/integration_spec.rb +3 -3
- data/lib/generators/minitest/integration/templates/integration_test.rb +3 -3
- data/lib/generators/minitest/job/job_generator.rb +2 -3
- data/lib/generators/minitest/job/templates/job_spec.rb +3 -3
- data/lib/generators/minitest/job/templates/job_test.rb +3 -3
- data/lib/generators/minitest/mailer/mailer_generator.rb +9 -4
- data/lib/generators/minitest/mailer/templates/mailer_spec.rb +4 -4
- data/lib/generators/minitest/mailer/templates/mailer_test.rb +5 -5
- data/lib/generators/minitest/mailer/templates/preview.rb +5 -5
- data/lib/generators/minitest/model/model_generator.rb +3 -4
- data/lib/generators/minitest/model/templates/fixtures.yml +17 -12
- data/lib/generators/minitest/scaffold/scaffold_generator.rb +24 -3
- data/lib/generators/minitest/scaffold/templates/api_controller_spec.rb +42 -0
- data/lib/generators/minitest/scaffold/templates/api_controller_test.rb +44 -0
- data/lib/generators/minitest/scaffold/templates/controller_spec.rb +14 -11
- data/lib/generators/minitest/scaffold/templates/controller_test.rb +17 -14
- data/lib/minitest/rails.rb +10 -27
- data/lib/minitest/rails/assertions.rb +0 -561
- data/lib/minitest/rails/expectations.rb +0 -63
- data/lib/minitest/rails/version.rb +1 -1
- data/minitest-rails.gemspec +13 -10
- data/tasks/test.rake +8 -8
- data/test/generators/test_helper_generator.rb +8 -16
- data/test/generators/test_mailer_generator.rb +16 -17
- data/test/generators/test_model_generator.rb +1 -1
- data/test/generators/test_scaffold_generator.rb +2 -2
- data/test/helper.rb +16 -1
- data/test/rails/{action_controller → action_dispatch}/test_assertions.rb +4 -11
- data/test/rails/{action_controller → action_dispatch}/test_expectations.rb +4 -11
- data/test/rails/action_dispatch/test_spec_type.rb +6 -18
- data/test/rails/action_mailer/test_mailers.rb +6 -6
- data/test/rails/action_view/test_helpers.rb +2 -2
- metadata +28 -21
- data/gemfiles/4.1.gemfile +0 -5
- data/gemfiles/4.2.gemfile +0 -5
- data/lib/generators/minitest/helper/templates/helper_spec.rb +0 -9
- data/lib/generators/minitest/helper/templates/helper_test.rb +0 -9
- data/lib/generators/minitest/route/route_generator.rb +0 -28
- data/lib/generators/minitest/route/templates/route_spec.rb +0 -13
- data/lib/generators/minitest/route/templates/route_test.rb +0 -13
- data/test/generators/test_route_generator.rb +0 -24
- data/test/rails/action_controller/test_controllers.rb +0 -202
- data/test/rails/action_controller/test_spec_type.rb +0 -47
- data/test/rails/minitest_5_api_test.rb +0 -8
@@ -54,7 +54,6 @@ module Minitest::Rails::Expectations
|
|
54
54
|
# must_respond_with 401
|
55
55
|
# value(response).must_respond_with 401
|
56
56
|
#
|
57
|
-
# See also ActionController::TestCase#assert_response
|
58
57
|
# See also ActionView::TestCase#assert_response
|
59
58
|
# See also ActionDispatch::IntegrationTest#assert_response
|
60
59
|
#
|
@@ -78,50 +77,12 @@ module Minitest::Rails::Expectations
|
|
78
77
|
# # expect that the redirection matches the regular expression
|
79
78
|
# must_redirect_to %r(\Ahttp://example.org)
|
80
79
|
#
|
81
|
-
# See also ActionController::TestCase#assert_redirected_to
|
82
80
|
# See also ActionView::TestCase#assert_redirected_to
|
83
81
|
# See also ActionDispatch::IntegrationTest#assert_redirected_to
|
84
82
|
#
|
85
83
|
# :method: must_redirect_to
|
86
84
|
# :call-seq: must_redirect_to(options = {}, message=nil)
|
87
85
|
|
88
|
-
##
|
89
|
-
# Expects that the request was rendered with the appropriate template file or partials.
|
90
|
-
#
|
91
|
-
# # expect that the "new" view template was rendered
|
92
|
-
# must_render_template "new"
|
93
|
-
#
|
94
|
-
# # expect that the exact template "admin/posts/new" was rendered
|
95
|
-
# must_render_template %r{\Aadmin/posts/new\Z}
|
96
|
-
#
|
97
|
-
# # expect that the layout 'admin' was rendered
|
98
|
-
# must_render_template layout: 'admin'
|
99
|
-
# must_render_template layout: 'layouts/admin'
|
100
|
-
# must_render_template layout: :admin
|
101
|
-
#
|
102
|
-
# # expect that no layout was rendered
|
103
|
-
# must_render_template layout: nil
|
104
|
-
# must_render_template layout: false
|
105
|
-
#
|
106
|
-
# # expect that the "_customer" partial was rendered twice
|
107
|
-
# must_render_template partial: '_customer', count: 2
|
108
|
-
#
|
109
|
-
# # expect that no partials were rendered
|
110
|
-
# must_render_template partial: false
|
111
|
-
#
|
112
|
-
# In a view test case, you can also expect that specific locals are passed
|
113
|
-
# to partials:
|
114
|
-
#
|
115
|
-
# # expect that the "_customer" partial was rendered with a specific object
|
116
|
-
# must_render_template partial: '_customer', locals: { customer: @customer }
|
117
|
-
#
|
118
|
-
# See also ActionController::TestCase#assert_template
|
119
|
-
# See also ActionView::TestCase#assert_template
|
120
|
-
# See also ActionDispatch::IntegrationTest#assert_template
|
121
|
-
#
|
122
|
-
# :method: must_render_template
|
123
|
-
# :call-seq: must_render_template(options = {}, message = nil)
|
124
|
-
|
125
86
|
##
|
126
87
|
# Expects that the provided options can be used to generate the provided path. This is the inverse of +assert_recognizes+.
|
127
88
|
# The +extras+ parameter is used to tell the request the names and values of additional request parameters that would be in
|
@@ -141,7 +102,6 @@ module Minitest::Rails::Expectations
|
|
141
102
|
# # Expects that the generated route gives us our custom route
|
142
103
|
# value({ controller: 'scm', action: 'show_diff', revision: "12" }).must_route_from "changesets/12"
|
143
104
|
#
|
144
|
-
# See also ActionController::TestCase#assert_generates
|
145
105
|
# See also ActionView::TestCase#assert_generates
|
146
106
|
# See also ActionDispatch::IntegrationTest#assert_generates
|
147
107
|
#
|
@@ -181,7 +141,6 @@ module Minitest::Rails::Expectations
|
|
181
141
|
# # Test a custom route
|
182
142
|
# value('view/item1').must_route_from({controller: 'items', action: 'show', id: '1'})
|
183
143
|
#
|
184
|
-
# See also ActionController::TestCase#assert_recognizes
|
185
144
|
# See also ActionView::TestCase#assert_recognizes
|
186
145
|
# See also ActionDispatch::IntegrationTest#assert_recognizes
|
187
146
|
#
|
@@ -212,7 +171,6 @@ module Minitest::Rails::Expectations
|
|
212
171
|
# # Tests a route with a HTTP method
|
213
172
|
# value({ controller: "product", action: "update", id: "321" }).must_route_for({ method: 'put', path: '/product/321' })
|
214
173
|
#
|
215
|
-
# See also ActionController::TestCase#assert_routing
|
216
174
|
# See also ActionView::TestCase#assert_routing
|
217
175
|
# See also ActionDispatch::IntegrationTest#assert_routing
|
218
176
|
#
|
@@ -308,7 +266,6 @@ module Minitest::Rails::Expectations
|
|
308
266
|
# must_select "[name=?]", /.+/ # Not empty
|
309
267
|
# end
|
310
268
|
#
|
311
|
-
# See also ActionController::TestCase#assert_select
|
312
269
|
# See also ActionView::TestCase#assert_select
|
313
270
|
# See also ActionDispatch::IntegrationTest#assert_select
|
314
271
|
#
|
@@ -331,7 +288,6 @@ module Minitest::Rails::Expectations
|
|
331
288
|
# end
|
332
289
|
# end
|
333
290
|
#
|
334
|
-
# See also ActionController::TestCase#assert_select_email
|
335
291
|
# See also ActionView::TestCase#assert_select_email
|
336
292
|
# See also ActionDispatch::IntegrationTest#assert_select_email
|
337
293
|
#
|
@@ -371,7 +327,6 @@ module Minitest::Rails::Expectations
|
|
371
327
|
# end
|
372
328
|
# end
|
373
329
|
#
|
374
|
-
# See also ActionController::TestCase#assert_select_encoded
|
375
330
|
# See also ActionView::TestCase#assert_select_encoded
|
376
331
|
# See also ActionDispatch::IntegrationTest#assert_select_encoded
|
377
332
|
#
|
@@ -385,7 +340,6 @@ module Minitest::Rails::Expectations
|
|
385
340
|
# apple_link = '<a href="http://www.example.com">Apples</a>'
|
386
341
|
# value(link_to("Apples", "http://www.example.com")).must_dom_equal apple_link
|
387
342
|
#
|
388
|
-
# See also ActionController::TestCase#assert_dom_equal
|
389
343
|
# See also ActionView::TestCase#assert_dom_equal
|
390
344
|
# See also ActionDispatch::IntegrationTest#assert_dom_equal
|
391
345
|
#
|
@@ -399,10 +353,8 @@ module Minitest::Rails::Expectations
|
|
399
353
|
# orange_link = '<a href="http://www.example.com">Oranges</a>'
|
400
354
|
# link_to("Apples", "http://www.example.com").wont_dom_equal orange_link
|
401
355
|
#
|
402
|
-
# See also ActionController::TestCase#refute_dom_equal
|
403
356
|
# See also ActionView::TestCase#refute_dom_equal
|
404
357
|
# See also ActionDispatch::IntegrationTest#refute_dom_equal
|
405
|
-
# See also ActionController::TestCase#assert_dom_not_equal
|
406
358
|
# See also ActionView::TestCase#assert_dom_not_equal
|
407
359
|
# See also ActionDispatch::IntegrationTest#assert_dom_not_equal
|
408
360
|
#
|
@@ -501,7 +453,6 @@ module Minitest::Rails::Expectations
|
|
501
453
|
# that allow optional closing tags (p, li, td). <em>You must explicitly
|
502
454
|
# close all of your tags to use these assertions.</em>
|
503
455
|
#
|
504
|
-
# See also ActionController::TestCase#assert_tag
|
505
456
|
# See also ActionView::TestCase#assert_tag
|
506
457
|
# See also ActionDispatch::IntegrationTest#assert_tag
|
507
458
|
#
|
@@ -523,10 +474,8 @@ module Minitest::Rails::Expectations
|
|
523
474
|
# wont_have_tag tag: "p",
|
524
475
|
# children: { count: 1..3, only: { tag: "img" } }
|
525
476
|
#
|
526
|
-
# See also ActionController::TestCase#refute_tag
|
527
477
|
# See also ActionView::TestCase#refute_tag
|
528
478
|
# See also ActionDispatch::IntegrationTest#refute_tag
|
529
|
-
# See also ActionController::TestCase#assert_no_tag
|
530
479
|
# See also ActionView::TestCase#assert_no_tag
|
531
480
|
# See also ActionDispatch::IntegrationTest#assert_no_tag
|
532
481
|
#
|
@@ -716,20 +665,9 @@ unless ENV["MT_NO_EXPECTATIONS"]
|
|
716
665
|
end
|
717
666
|
# Not real expectations, just aliases
|
718
667
|
# The error messages don't get messed up this way
|
719
|
-
class ActionController::TestCase # :nodoc:
|
720
|
-
alias :must_respond_with :assert_response
|
721
|
-
alias :must_redirect_to :assert_redirected_to
|
722
|
-
alias :must_render_template :assert_template
|
723
|
-
alias :must_have_tag :assert_tag
|
724
|
-
alias :wont_have_tag :assert_no_tag
|
725
|
-
alias :must_select :assert_select
|
726
|
-
alias :must_select_email :assert_select_email
|
727
|
-
alias :must_select_encoded :assert_select_encoded
|
728
|
-
end
|
729
668
|
class ActionView::TestCase # :nodoc:
|
730
669
|
alias :must_respond_with :assert_response
|
731
670
|
alias :must_redirect_to :assert_redirected_to
|
732
|
-
alias :must_render_template :assert_template
|
733
671
|
alias :must_have_tag :assert_tag
|
734
672
|
alias :wont_have_tag :assert_no_tag
|
735
673
|
alias :must_select :assert_select
|
@@ -742,7 +680,6 @@ unless ENV["MT_NO_EXPECTATIONS"]
|
|
742
680
|
class ActionDispatch::IntegrationTest # :nodoc:
|
743
681
|
alias :must_respond_with :assert_response
|
744
682
|
alias :must_redirect_to :assert_redirected_to
|
745
|
-
alias :must_render_template :assert_template
|
746
683
|
alias :must_have_tag :assert_tag
|
747
684
|
alias :wont_have_tag :assert_no_tag
|
748
685
|
alias :must_select :assert_select
|
data/minitest-rails.gemspec
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: minitest-rails
|
2
|
+
# stub: minitest-rails 3.0.0.rc1.20160507123149 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "minitest-rails".freeze
|
6
|
-
s.version = "
|
6
|
+
s.version = "3.0.0.rc1.20160507123149"
|
7
7
|
|
8
|
-
s.required_rubygems_version = Gem::Requirement.new("
|
8
|
+
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
10
10
|
s.authors = ["Mike Moore".freeze]
|
11
11
|
s.date = "2016-05-07"
|
12
12
|
s.description = "Adds Minitest as the default testing library in Rails".freeze
|
13
13
|
s.email = ["mike@blowmage.com".freeze]
|
14
14
|
s.extra_rdoc_files = ["CHANGELOG.rdoc".freeze, "Manifest.txt".freeze, "README.rdoc".freeze]
|
15
|
-
s.files = [".autotest".freeze, ".gemtest".freeze, ".travis.yml".freeze, "CHANGELOG.rdoc".freeze, "Gemfile".freeze, "LICENSE".freeze, "Manifest.txt".freeze, "README.rdoc".freeze, "Rakefile".freeze, "gemfiles/
|
15
|
+
s.files = [".autotest".freeze, ".gemtest".freeze, ".travis.yml".freeze, "CHANGELOG.rdoc".freeze, "Gemfile".freeze, "LICENSE".freeze, "Manifest.txt".freeze, "README.rdoc".freeze, "Rakefile".freeze, "gemfiles/5.0.gemfile".freeze, "gemfiles/head.gemfile".freeze, "lib/generators/.document".freeze, "lib/generators/minitest.rb".freeze, "lib/generators/minitest/controller/controller_generator.rb".freeze, "lib/generators/minitest/controller/templates/controller_spec.rb".freeze, "lib/generators/minitest/controller/templates/controller_test.rb".freeze, "lib/generators/minitest/generator/generator_generator.rb".freeze, "lib/generators/minitest/generator/templates/generator_spec.rb".freeze, "lib/generators/minitest/generator/templates/generator_test.rb".freeze, "lib/generators/minitest/helper/helper_generator.rb".freeze, "lib/generators/minitest/install/install_generator.rb".freeze, "lib/generators/minitest/install/templates/test_helper.rb".freeze, "lib/generators/minitest/integration/integration_generator.rb".freeze, "lib/generators/minitest/integration/templates/integration_spec.rb".freeze, "lib/generators/minitest/integration/templates/integration_test.rb".freeze, "lib/generators/minitest/job/job_generator.rb".freeze, "lib/generators/minitest/job/templates/job_spec.rb".freeze, "lib/generators/minitest/job/templates/job_test.rb".freeze, "lib/generators/minitest/mailer/mailer_generator.rb".freeze, "lib/generators/minitest/mailer/templates/mailer_spec.rb".freeze, "lib/generators/minitest/mailer/templates/mailer_test.rb".freeze, "lib/generators/minitest/mailer/templates/preview.rb".freeze, "lib/generators/minitest/model/model_generator.rb".freeze, "lib/generators/minitest/model/templates/fixtures.yml".freeze, "lib/generators/minitest/model/templates/model_spec.rb".freeze, "lib/generators/minitest/model/templates/model_test.rb".freeze, "lib/generators/minitest/scaffold/scaffold_generator.rb".freeze, "lib/generators/minitest/scaffold/templates/api_controller_spec.rb".freeze, "lib/generators/minitest/scaffold/templates/api_controller_test.rb".freeze, "lib/generators/minitest/scaffold/templates/controller_spec.rb".freeze, "lib/generators/minitest/scaffold/templates/controller_test.rb".freeze, "lib/minitest-rails.rb".freeze, "lib/minitest/rails.rb".freeze, "lib/minitest/rails/assertions.rb".freeze, "lib/minitest/rails/constant_lookup.rb".freeze, "lib/minitest/rails/expectations.rb".freeze, "lib/minitest/rails/railtie.rb".freeze, "lib/minitest/rails/version.rb".freeze, "minitest-rails.gemspec".freeze, "tasks/test.rake".freeze, "test/generators/test_controller_generator.rb".freeze, "test/generators/test_generator_generator.rb".freeze, "test/generators/test_helper_generator.rb".freeze, "test/generators/test_install_generator.rb".freeze, "test/generators/test_job_generator.rb".freeze, "test/generators/test_mailer_generator.rb".freeze, "test/generators/test_model_generator.rb".freeze, "test/generators/test_scaffold_generator.rb".freeze, "test/helper.rb".freeze, "test/rails/action_dispatch/test_assertions.rb".freeze, "test/rails/action_dispatch/test_expectations.rb".freeze, "test/rails/action_dispatch/test_spec_type.rb".freeze, "test/rails/action_mailer/test_mailers.rb".freeze, "test/rails/action_mailer/test_spec_type.rb".freeze, "test/rails/action_view/test_helpers.rb".freeze, "test/rails/action_view/test_spec_type.rb".freeze, "test/rails/active_job/test_assertions.rb".freeze, "test/rails/active_job/test_expectations.rb".freeze, "test/rails/active_job/test_spec_type.rb".freeze, "test/rails/active_support/test_assertions.rb".freeze, "test/rails/active_support/test_expectations.rb".freeze, "test/rails/active_support/test_spec_type.rb".freeze, "test/rails/generators/test_spec_type.rb".freeze, "test/rails/test_constant_lookup.rb".freeze, "test/test_sanity.rb".freeze]
|
16
16
|
s.homepage = "http://blowmage.com/minitest-rails".freeze
|
17
17
|
s.licenses = ["MIT".freeze]
|
18
18
|
s.rdoc_options = ["--main".freeze, "README.rdoc".freeze]
|
@@ -23,23 +23,26 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.specification_version = 4
|
24
24
|
|
25
25
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
26
|
-
s.add_runtime_dependency(%q<minitest>.freeze, ["~> 5.
|
27
|
-
s.add_runtime_dependency(%q<railties>.freeze, ["~>
|
26
|
+
s.add_runtime_dependency(%q<minitest>.freeze, ["~> 5.8"])
|
27
|
+
s.add_runtime_dependency(%q<railties>.freeze, ["~> 5.0.0.rc1"])
|
28
28
|
s.add_development_dependency(%q<rdoc>.freeze, ["~> 4.0"])
|
29
29
|
s.add_development_dependency(%q<fakefs>.freeze, ["= 0.4.3"])
|
30
|
+
s.add_development_dependency(%q<minitest-focus>.freeze, ["~> 1.1"])
|
30
31
|
s.add_development_dependency(%q<hoe>.freeze, ["~> 3.15"])
|
31
32
|
else
|
32
|
-
s.add_dependency(%q<minitest>.freeze, ["~> 5.
|
33
|
-
s.add_dependency(%q<railties>.freeze, ["~>
|
33
|
+
s.add_dependency(%q<minitest>.freeze, ["~> 5.8"])
|
34
|
+
s.add_dependency(%q<railties>.freeze, ["~> 5.0.0.rc1"])
|
34
35
|
s.add_dependency(%q<rdoc>.freeze, ["~> 4.0"])
|
35
36
|
s.add_dependency(%q<fakefs>.freeze, ["= 0.4.3"])
|
37
|
+
s.add_dependency(%q<minitest-focus>.freeze, ["~> 1.1"])
|
36
38
|
s.add_dependency(%q<hoe>.freeze, ["~> 3.15"])
|
37
39
|
end
|
38
40
|
else
|
39
|
-
s.add_dependency(%q<minitest>.freeze, ["~> 5.
|
40
|
-
s.add_dependency(%q<railties>.freeze, ["~>
|
41
|
+
s.add_dependency(%q<minitest>.freeze, ["~> 5.8"])
|
42
|
+
s.add_dependency(%q<railties>.freeze, ["~> 5.0.0.rc1"])
|
41
43
|
s.add_dependency(%q<rdoc>.freeze, ["~> 4.0"])
|
42
44
|
s.add_dependency(%q<fakefs>.freeze, ["= 0.4.3"])
|
45
|
+
s.add_dependency(%q<minitest-focus>.freeze, ["~> 1.1"])
|
43
46
|
s.add_dependency(%q<hoe>.freeze, ["~> 3.15"])
|
44
47
|
end
|
45
48
|
end
|
data/tasks/test.rake
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
namespace :test do
|
2
|
-
desc "Run tests for Rails
|
3
|
-
task "
|
2
|
+
desc "Run tests for Rails 5.0"
|
3
|
+
task "5.0" do
|
4
4
|
sh "rm -f Gemfile.lock"
|
5
|
-
ENV["RAILS_VERSION"] = "
|
5
|
+
ENV["RAILS_VERSION"] = "5.0"
|
6
6
|
sh "bundle && bundle exec rake test"
|
7
7
|
sh "rm -f Gemfile.lock"
|
8
8
|
end
|
9
9
|
|
10
|
-
desc "Run tests for Rails
|
11
|
-
task "
|
10
|
+
desc "Run tests for Rails head"
|
11
|
+
task "head" do
|
12
12
|
sh "rm -f Gemfile.lock"
|
13
|
-
ENV["RAILS_VERSION"] = "
|
13
|
+
ENV["RAILS_VERSION"] = "head"
|
14
14
|
sh "bundle && bundle exec rake test"
|
15
15
|
sh "rm -f Gemfile.lock"
|
16
16
|
end
|
17
17
|
|
18
18
|
desc "Run tests for all Rails versions"
|
19
19
|
task "all" do
|
20
|
-
sh "rake test:
|
21
|
-
sh "rake test:
|
20
|
+
sh "rake test:5.0"
|
21
|
+
sh "rake test:head"
|
22
22
|
end
|
23
23
|
end
|
@@ -4,39 +4,31 @@ require "generators/minitest/helper/helper_generator"
|
|
4
4
|
class TestHelperGenerator < GeneratorTest
|
5
5
|
|
6
6
|
def test_helper_generator
|
7
|
-
|
7
|
+
refute_output(/create test\/helpers\/user_helper_test.rb/m) do
|
8
8
|
Minitest::Generators::HelperGenerator.start ["user"]
|
9
9
|
end
|
10
|
-
|
11
|
-
contents = File.read "test/helpers/user_helper_test.rb"
|
12
|
-
assert_match(/class UserHelperTest < ActionView::TestCase/m, contents)
|
10
|
+
refute File.exists? "test/helpers/user_helper_test.rb"
|
13
11
|
end
|
14
12
|
|
15
13
|
def test_namespaced_helper_generator
|
16
|
-
|
14
|
+
refute_output(/create test\/helpers\/admin\/user_helper_test.rb/m) do
|
17
15
|
Minitest::Generators::HelperGenerator.start ["admin/user"]
|
18
16
|
end
|
19
|
-
|
20
|
-
contents = File.read "test/helpers/admin/user_helper_test.rb"
|
21
|
-
assert_match(/class Admin::UserHelperTest < ActionView::TestCase/m, contents)
|
17
|
+
refute File.exists? "test/helpers/admin/user_helper_test.rb"
|
22
18
|
end
|
23
19
|
|
24
20
|
def test_helper_generator_spec
|
25
|
-
|
21
|
+
refute_output(/create test\/helpers\/user_helper_test.rb/m) do
|
26
22
|
Minitest::Generators::HelperGenerator.start ["user", "--spec"]
|
27
23
|
end
|
28
|
-
|
29
|
-
contents = File.read "test/helpers/user_helper_test.rb"
|
30
|
-
assert_match(/describe UserHelper do/m, contents)
|
24
|
+
refute File.exists? "test/helpers/user_helper_test.rb"
|
31
25
|
end
|
32
26
|
|
33
27
|
def test_namespaced_helper_generator_spec
|
34
|
-
|
28
|
+
refute_output(/create test\/helpers\/admin\/user_helper_test.rb/m) do
|
35
29
|
Minitest::Generators::HelperGenerator.start ["admin/user", "--spec"]
|
36
30
|
end
|
37
|
-
|
38
|
-
contents = File.read "test/helpers/admin/user_helper_test.rb"
|
39
|
-
assert_match(/describe Admin::UserHelper do/m, contents)
|
31
|
+
refute File.exists? "test/helpers/admin/user_helper_test.rb"
|
40
32
|
end
|
41
33
|
|
42
34
|
end
|
@@ -4,40 +4,39 @@ require "generators/minitest/mailer/mailer_generator"
|
|
4
4
|
class TestMailerGenerator < GeneratorTest
|
5
5
|
|
6
6
|
def test_mailer_generator
|
7
|
-
assert_output(/create test\/mailers\/
|
7
|
+
assert_output(/create test\/mailers\/notification_mailer_test.rb/m) do
|
8
8
|
Minitest::Generators::MailerGenerator.start ["notification"]
|
9
9
|
end
|
10
|
-
assert File.exists? "test/mailers/
|
11
|
-
contents = File.read "test/mailers/
|
12
|
-
assert_match(/class
|
10
|
+
assert File.exists? "test/mailers/notification_mailer_test.rb"
|
11
|
+
contents = File.read "test/mailers/notification_mailer_test.rb"
|
12
|
+
assert_match(/class NotificationMailerTest/m, contents)
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_namespaced_mailer_generator
|
16
|
-
assert_output(/create test\/mailers\/admin\/
|
16
|
+
assert_output(/create test\/mailers\/admin\/notification_mailer_test.rb/m) do
|
17
17
|
Minitest::Generators::MailerGenerator.start ["admin/notification"]
|
18
18
|
end
|
19
|
-
assert File.exists? "test/mailers/admin/
|
20
|
-
contents = File.read "test/mailers/admin/
|
21
|
-
assert_match(/class Admin::
|
19
|
+
assert File.exists? "test/mailers/admin/notification_mailer_test.rb"
|
20
|
+
contents = File.read "test/mailers/admin/notification_mailer_test.rb"
|
21
|
+
assert_match(/class Admin::NotificationMailerTest/m, contents)
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_mailer_generator_spec
|
25
|
-
assert_output(/create test\/mailers\/
|
25
|
+
assert_output(/create test\/mailers\/notification_mailer_test.rb/m) do
|
26
26
|
Minitest::Generators::MailerGenerator.start ["notification", "welcome", "--spec"]
|
27
27
|
end
|
28
|
-
assert File.exists? "test/mailers/
|
29
|
-
contents = File.read "test/mailers/
|
30
|
-
assert_match(/describe
|
28
|
+
assert File.exists? "test/mailers/notification_mailer_test.rb"
|
29
|
+
contents = File.read "test/mailers/notification_mailer_test.rb"
|
30
|
+
assert_match(/describe NotificationMailer do/m, contents)
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_namespaced_mailer_generator_spec
|
34
|
-
assert_output(/create test\/mailers\/admin\/
|
34
|
+
assert_output(/create test\/mailers\/admin\/notification_mailer_test.rb/m) do
|
35
35
|
Minitest::Generators::MailerGenerator.start ["admin/notification", "welcome", "--spec"]
|
36
36
|
end
|
37
|
-
assert File.exists? "test/mailers/admin/
|
38
|
-
contents = File.read "test/mailers/admin/
|
39
|
-
assert_match(/describe Admin::
|
37
|
+
assert File.exists? "test/mailers/admin/notification_mailer_test.rb"
|
38
|
+
contents = File.read "test/mailers/admin/notification_mailer_test.rb"
|
39
|
+
assert_match(/describe Admin::NotificationMailer do/m, contents)
|
40
40
|
end
|
41
41
|
|
42
|
-
|
43
42
|
end
|
@@ -42,7 +42,7 @@ class TestModelGenerator < GeneratorTest
|
|
42
42
|
Minitest::Generators::ModelGenerator.start ["user", "--spec"]
|
43
43
|
end
|
44
44
|
assert File.exists? "test/models/user_test.rb"
|
45
|
-
assert File.exists? "test/fixtures/users.yml"
|
45
|
+
# assert File.exists? "test/fixtures/users.yml"
|
46
46
|
contents = File.read "test/models/user_test.rb"
|
47
47
|
assert_match(/describe User do/m, contents)
|
48
48
|
end
|
@@ -10,7 +10,7 @@ class TestScaffoldGenerator < GeneratorTest
|
|
10
10
|
assert File.exists? "test/controllers/users_controller_test.rb"
|
11
11
|
contents = File.read "test/controllers/users_controller_test.rb"
|
12
12
|
assert_match(/class UsersControllerTest/m, contents)
|
13
|
-
assert_match(/post
|
13
|
+
assert_match(/post users_url, params: { user: { email: user.email, name: user.name } }/m, contents)
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_scaffold_generator_spec
|
@@ -20,7 +20,7 @@ class TestScaffoldGenerator < GeneratorTest
|
|
20
20
|
assert File.exists? "test/controllers/users_controller_test.rb"
|
21
21
|
contents = File.read "test/controllers/users_controller_test.rb"
|
22
22
|
assert_match(/describe UsersController do/m, contents)
|
23
|
-
assert_match(/post
|
23
|
+
assert_match(/post users_url, params: { user: { email: user.email, name: user.name } }/m, contents)
|
24
24
|
end
|
25
25
|
|
26
26
|
end
|
data/test/helper.rb
CHANGED
@@ -20,6 +20,7 @@ require "minitest-rails"
|
|
20
20
|
require "rails/test_help"
|
21
21
|
require "minitest/rails"
|
22
22
|
|
23
|
+
require "minitest/focus"
|
23
24
|
require "fakefs/safe"
|
24
25
|
|
25
26
|
class FakeFS::File
|
@@ -39,6 +40,20 @@ class GeneratorTest < Minitest::Test
|
|
39
40
|
FakeFS::FileSystem.clear
|
40
41
|
FakeFS.deactivate!
|
41
42
|
end
|
43
|
+
|
44
|
+
def refute_output stdout = nil, stderr = nil
|
45
|
+
out, err = capture_io do
|
46
|
+
yield
|
47
|
+
end
|
48
|
+
|
49
|
+
err_msg = Regexp === stderr ? :refute_match : :refute_equal if stderr
|
50
|
+
out_msg = Regexp === stdout ? :refute_match : :refute_equal if stdout
|
51
|
+
|
52
|
+
y = send err_msg, stderr, err, "In stderr" if err_msg
|
53
|
+
x = send out_msg, stdout, out, "In stdout" if out_msg
|
54
|
+
|
55
|
+
(!stdout || x) && (!stderr || y)
|
56
|
+
end
|
42
57
|
end
|
43
58
|
|
44
59
|
require "rails/test_help"
|
@@ -54,7 +69,7 @@ TestApp::Application.initialize!
|
|
54
69
|
|
55
70
|
class ApplicationController < ActionController::Base; end
|
56
71
|
class ModelsController < ApplicationController
|
57
|
-
def index; render :
|
72
|
+
def index; render html: "<html><head><title>Models</title></head><body><h1>All <em>Models</em></h1></body></html>".html_safe; end
|
58
73
|
def new; redirect_to "/models"; end
|
59
74
|
end
|
60
75
|
module Admin
|
@@ -1,23 +1,16 @@
|
|
1
1
|
require "helper"
|
2
2
|
|
3
|
-
class
|
4
|
-
tests ModelsController
|
5
|
-
|
3
|
+
class TestIntegrationAssertions < ActionDispatch::IntegrationTest
|
6
4
|
def test_assert_response
|
7
|
-
get
|
5
|
+
get models_path
|
8
6
|
assert_response :success
|
9
7
|
end
|
10
8
|
|
11
9
|
def test_assert_redirected_to
|
12
|
-
get
|
10
|
+
get new_model_path
|
13
11
|
assert_redirected_to :models
|
14
12
|
end
|
15
13
|
|
16
|
-
def test_assert_template
|
17
|
-
get :index
|
18
|
-
assert_template :layout => false
|
19
|
-
end
|
20
|
-
|
21
14
|
def test_routing_assertions
|
22
15
|
params = { :controller => "models", :action => "index" }
|
23
16
|
path = "/models"
|
@@ -37,7 +30,7 @@ class TestActionControllerAssertions < ActionController::TestCase
|
|
37
30
|
end
|
38
31
|
|
39
32
|
def test_assert_select
|
40
|
-
get
|
33
|
+
get models_path
|
41
34
|
assert_select "body h1"
|
42
35
|
assert_select "body" do
|
43
36
|
assert_select "h1"
|