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.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -3
  3. data/CHANGELOG.rdoc +9 -0
  4. data/Gemfile +1 -1
  5. data/Manifest.txt +8 -0
  6. data/Rakefile +1 -1
  7. data/gemfiles/4.2.gemfile +5 -0
  8. data/lib/generators/minitest/controller/templates/controller_spec.rb +1 -1
  9. data/lib/generators/minitest/helper/templates/helper_spec.rb +0 -2
  10. data/lib/generators/minitest/helper/templates/helper_test.rb +0 -2
  11. data/lib/generators/minitest/install/install_generator.rb +1 -6
  12. data/lib/generators/minitest/install/templates/test_helper.rb +2 -10
  13. data/lib/generators/minitest/job/job_generator.rb +19 -0
  14. data/lib/generators/minitest/job/templates/job_spec.rb +9 -0
  15. data/lib/generators/minitest/job/templates/job_test.rb +9 -0
  16. data/lib/generators/minitest/mailer/templates/mailer_spec.rb +4 -4
  17. data/lib/generators/minitest/model/templates/model_spec.rb +1 -1
  18. data/lib/generators/minitest/model/templates/model_test.rb +0 -2
  19. data/lib/generators/minitest/route/templates/route_spec.rb +5 -2
  20. data/lib/generators/minitest/route/templates/route_test.rb +4 -1
  21. data/lib/generators/minitest/scaffold/templates/controller_spec.rb +12 -14
  22. data/lib/generators/minitest/scaffold/templates/controller_test.rb +2 -3
  23. data/lib/minitest/rails.rb +16 -3
  24. data/lib/minitest/rails/assertions.rb +223 -1
  25. data/lib/minitest/rails/expectations.rb +205 -24
  26. data/lib/minitest/rails/version.rb +1 -1
  27. data/minitest-rails.gemspec +11 -12
  28. data/tasks/test.rake +9 -0
  29. data/test/generators/test_install_generator.rb +0 -6
  30. data/test/generators/test_job_generator.rb +45 -0
  31. data/test/helper.rb +12 -0
  32. data/test/rails/action_controller/test_expectations.rb +6 -5
  33. data/test/rails/active_job/test_assertions.rb +46 -0
  34. data/test/rails/active_job/test_expectations.rb +55 -0
  35. data/test/rails/active_job/test_spec_type.rb +49 -0
  36. data/test/rails/active_support/test_expectations.rb +4 -4
  37. metadata +14 -30
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf6577b6ce6d9da859bf47767f13696600ec474a
4
- data.tar.gz: 07223c98e27cc1be07834eb3865fc6c51b461056
3
+ metadata.gz: 68edb1de24a345b79b62a8e72d7dc4440d50a6cf
4
+ data.tar.gz: bf11388632659cbdcab89ea106957f27e38ba00f
5
5
  SHA512:
6
- metadata.gz: dbc04982898fed29de7fd1cace702da2ec6e3b2f60dca3be344545108b1a714425233860d52c4aeb5965e6f0f67b478291318e5898eb4890b4a43e71466e48ba
7
- data.tar.gz: 2d5d3654e42f3e4386ee948ba4d1d8eb5568e895679f270596c71da0a9ddbfb4f8be9720667e98cba6c429893134b7b2d831cdeeeb8a1c559a4801982d444a1e
6
+ metadata.gz: af1b2cba09d025f60ef74a88babcb2170360e87e5c3f151bcae5176b4683b43b8c2f442b1a2e96ad03d5836f7389929d6250a3a74a59198d5061fe7ceb75bc64
7
+ data.tar.gz: 9be6b040a720d5f91943e251cb7fc74a587e31b63b52d4fe5a2a9fbde92ed104b7e4320081c6dcd7360721c6e3330f3c063fb0e2a95343dcfcb021bf71413cac
@@ -7,12 +7,13 @@ notifications:
7
7
  email:
8
8
  - mike@blowmage.com
9
9
  rvm:
10
- - 2.1.1
11
- - 2.1.0
12
- - 2.0.0
10
+ - 2.2
11
+ - 2.1
12
+ - 2.0
13
13
  - 1.9.3
14
14
  env:
15
15
  - "RAILS_VERSION=4.1"
16
+ - "RAILS_VERSION=4.2"
16
17
  notifications:
17
18
  webhooks:
18
19
  urls:
@@ -1,3 +1,12 @@
1
+ === 2.2.0 / 2015-05-29
2
+
3
+ * Update to Minitest 5.7
4
+ * Use Value Monad for Expectations
5
+ * Active Job support (liseki)
6
+ * Documentation improvements (WendyBeth)
7
+
8
+ https://github.com/blowmage/minitest-rails/compare/v2.1.1...v2.2.0
9
+
1
10
  === 2.1.1 / 2014-10-28
2
11
 
3
12
  * Fix scaffold generator to use accessor instead of ivar (isaacsloan)
data/Gemfile CHANGED
@@ -2,6 +2,6 @@ source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- version = ENV["RAILS_VERSION"] || "4.1"
5
+ version = ENV["RAILS_VERSION"] || "4.2"
6
6
 
7
7
  eval_gemfile File.expand_path("../gemfiles/#{version}.gemfile", __FILE__)
@@ -8,6 +8,7 @@ Manifest.txt
8
8
  README.rdoc
9
9
  Rakefile
10
10
  gemfiles/4.1.gemfile
11
+ gemfiles/4.2.gemfile
11
12
  lib/generators/.document
12
13
  lib/generators/minitest.rb
13
14
  lib/generators/minitest/controller/controller_generator.rb
@@ -24,6 +25,9 @@ lib/generators/minitest/install/templates/test_helper.rb
24
25
  lib/generators/minitest/integration/integration_generator.rb
25
26
  lib/generators/minitest/integration/templates/integration_spec.rb
26
27
  lib/generators/minitest/integration/templates/integration_test.rb
28
+ lib/generators/minitest/job/job_generator.rb
29
+ lib/generators/minitest/job/templates/job_spec.rb
30
+ lib/generators/minitest/job/templates/job_test.rb
27
31
  lib/generators/minitest/mailer/mailer_generator.rb
28
32
  lib/generators/minitest/mailer/templates/mailer_spec.rb
29
33
  lib/generators/minitest/mailer/templates/mailer_test.rb
@@ -51,6 +55,7 @@ test/generators/test_controller_generator.rb
51
55
  test/generators/test_generator_generator.rb
52
56
  test/generators/test_helper_generator.rb
53
57
  test/generators/test_install_generator.rb
58
+ test/generators/test_job_generator.rb
54
59
  test/generators/test_mailer_generator.rb
55
60
  test/generators/test_model_generator.rb
56
61
  test/generators/test_route_generator.rb
@@ -65,6 +70,9 @@ test/rails/action_mailer/test_mailers.rb
65
70
  test/rails/action_mailer/test_spec_type.rb
66
71
  test/rails/action_view/test_helpers.rb
67
72
  test/rails/action_view/test_spec_type.rb
73
+ test/rails/active_job/test_assertions.rb
74
+ test/rails/active_job/test_expectations.rb
75
+ test/rails/active_job/test_spec_type.rb
68
76
  test/rails/active_support/test_assertions.rb
69
77
  test/rails/active_support/test_expectations.rb
70
78
  test/rails/active_support/test_spec_type.rb
data/Rakefile CHANGED
@@ -19,7 +19,7 @@ Hoe.spec "minitest-rails" do
19
19
 
20
20
  license "MIT"
21
21
 
22
- dependency "minitest", "~> 5.4"
22
+ dependency "minitest", "~> 5.7"
23
23
  dependency "railties", "~> 4.1"
24
24
  dependency "fakefs", "= 0.4.3", :dev
25
25
  end
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "rails", "~> 4.2.0"
4
+ gem "sqlite3"
5
+ gem "rake"
@@ -10,7 +10,7 @@ describe <%= class_name %>Controller do
10
10
  <% actions.each do |action| -%>
11
11
  it "should get <%= action %>" do
12
12
  get :<%= action %>
13
- assert_response :success
13
+ value(response).must_be :success?
14
14
  end
15
15
 
16
16
  <% end -%>
@@ -2,10 +2,8 @@ require "test_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
4
  describe <%= class_name %>Helper do
5
-
6
5
  it "must be a real test" do
7
6
  flunk "Need real tests"
8
7
  end
9
-
10
8
  end
11
9
  <% end -%>
@@ -2,10 +2,8 @@ require "test_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
4
  class <%= class_name %>HelperTest < ActionView::TestCase
5
-
6
5
  def test_sanity
7
6
  flunk "Need real tests"
8
7
  end
9
-
10
8
  end
11
9
  <% end -%>
@@ -3,7 +3,7 @@ require 'rails/generators'
3
3
  module Minitest
4
4
  module Generators
5
5
  class InstallGenerator < ::Rails::Generators::Base
6
- class_option :active_record, type: :boolean, default: true, desc: "Add ActiveRecord configuration"
6
+ class_option :skip_active_record, type: :boolean, default: false, desc: "Skip Active Record files"
7
7
 
8
8
  desc <<DESC
9
9
  Description:
@@ -17,11 +17,6 @@ DESC
17
17
  def copy_minitest_files
18
18
  template 'test_helper.rb', File.join("test", "test_helper.rb")
19
19
  end
20
-
21
- def add_migration_check
22
- ::Rails::VERSION::STRING >= "4.0"
23
- end
24
-
25
20
  end
26
21
  end
27
22
  end
@@ -11,17 +11,9 @@ require "minitest/rails"
11
11
  # require "minitest/pride"
12
12
 
13
13
  class ActiveSupport::TestCase
14
- <% if options[:active_record] -%>
15
- <% if add_migration_check -%>
16
- ActiveRecord::Migration.check_pending!
17
-
18
- <% end -%>
19
- # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
20
- #
21
- # Note: You'll currently still have to declare fixtures explicitly in integration tests
22
- # -- they do not yet inherit this setting
14
+ <% unless options[:skip_active_record] -%>
15
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
23
16
  fixtures :all
24
-
25
17
  <% end -%>
26
18
  # Add more helper methods to be used by all tests here...
27
19
  end
@@ -0,0 +1,19 @@
1
+ require "generators/minitest"
2
+
3
+ module Minitest
4
+ module Generators
5
+ class JobGenerator < Base
6
+ check_class_collision suffix: 'JobTest'
7
+
8
+ def create_test_files
9
+ if options[:spec]
10
+ template_file = "job_spec.rb"
11
+ else
12
+ template_file = "job_test.rb"
13
+ end
14
+ template template_file,
15
+ File.join("test/jobs", class_path, "#{file_name}_job_test.rb")
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,9 @@
1
+ require "test_helper"
2
+
3
+ <% module_namespacing do -%>
4
+ describe <%= class_name %>Job do
5
+ it "must be a real test" do
6
+ flunk "Need real tests"
7
+ end
8
+ end
9
+ <% end -%>
@@ -0,0 +1,9 @@
1
+ require "test_helper"
2
+
3
+ <% module_namespacing do -%>
4
+ class <%= class_name %>JobTest < ActiveJob::TestCase
5
+ def test_sanity
6
+ flunk "Need real tests"
7
+ end
8
+ end
9
+ <% end -%>
@@ -5,10 +5,10 @@ describe <%= class_name %> do
5
5
  <% actions.each do |action| -%>
6
6
  it "<%= action %>" do
7
7
  mail = <%= class_name %>.<%= action %>
8
- mail.subject.must_equal <%= action.to_s.humanize.inspect %>
9
- mail.to.must_equal ["to@example.org"]
10
- mail.from.must_equal ["from@example.com"]
11
- mail.body.encoded.must_match "Hi"
8
+ value(mail.subject).must_equal <%= action.to_s.humanize.inspect %>
9
+ value(mail.to).must_equal ["to@example.org"]
10
+ value(mail.from).must_equal ["from@example.com"]
11
+ value(mail.body.encoded).must_match "Hi"
12
12
  end
13
13
  <% end -%>
14
14
  <% if actions.blank? -%>
@@ -5,7 +5,7 @@ describe <%= class_name %> do
5
5
  let(:<%= file_name %>) { <%= class_name %>.new }
6
6
 
7
7
  it "must be valid" do
8
- <%= file_name %>.must_be :valid?
8
+ value(<%= file_name %>).must_be :valid?
9
9
  end
10
10
  end
11
11
  <% end -%>
@@ -2,7 +2,6 @@ require "test_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
4
  class <%= class_name %>Test < ActiveSupport::TestCase
5
-
6
5
  def <%= file_name %>
7
6
  @<%= file_name %> ||= <%= class_name %>.new
8
7
  end
@@ -10,6 +9,5 @@ class <%= class_name %>Test < ActiveSupport::TestCase
10
9
  def test_valid
11
10
  assert <%= file_name %>.valid?
12
11
  end
13
-
14
12
  end
15
13
  <% end -%>
@@ -1,10 +1,13 @@
1
1
  require "test_helper"
2
2
 
3
3
  # Add the following to your Rake file to test routes by default:
4
- # Minitest::Rails::Testing.default_tasks << "routes"
4
+ # Rails::TestTask.new("test:routes" => "test:prepare") do |t|
5
+ # t.pattern = "test/routes/**/*_test.rb"
6
+ # end
7
+ # Rake::Task["test:run"].enhance ["test:routes"]
5
8
 
6
9
  describe "Route Integration Test" do
7
10
  it "route root" do
8
- assert_routing "/", controller: "home", action: "show"
11
+ must_route "/", controller: "home", action: "show"
9
12
  end
10
13
  end
@@ -1,7 +1,10 @@
1
1
  require "test_helper"
2
2
 
3
3
  # Add the following to your Rake file to test routes by default:
4
- # Minitest::Rails::Testing.default_tasks << "routes"
4
+ # Rails::TestTask.new("test:routes" => "test:prepare") do |t|
5
+ # t.pattern = "test/routes/**/*_test.rb"
6
+ # end
7
+ # Rake::Task["test:run"].enhance ["test:routes"]
5
8
 
6
9
  class RouteTest < ActionDispatch::IntegrationTest
7
10
  def test_root
@@ -2,50 +2,48 @@ require "test_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
4
  describe <%= controller_class_name %>Controller do
5
-
6
5
  let(:<%= singular_table_name %>) { <%= table_name %> :one }
7
6
 
8
7
  it "gets index" do
9
8
  get :index
10
- assert_response :success
11
- assert_not_nil assigns(:<%= table_name %>)
9
+ value(response).must_be :success?
10
+ value(assigns(:<%= table_name %>)).wont_be :nil?
12
11
  end
13
12
 
14
13
  it "gets new" do
15
14
  get :new
16
- assert_response :success
15
+ value(response).must_be :success?
17
16
  end
18
17
 
19
18
  it "creates <%= singular_table_name %>" do
20
- assert_difference('<%= class_name %>.count') do
19
+ expect {
21
20
  post :create, <%= "#{singular_table_name}: { #{attributes_hash} }" %>
22
- end
21
+ }.must_change "<%= class_name %>.count"
23
22
 
24
- assert_redirected_to <%= singular_table_name %>_path(assigns(:<%= singular_table_name %>))
23
+ must_redirect_to <%= singular_table_name %>_path(assigns(:<%= singular_table_name %>))
25
24
  end
26
25
 
27
26
  it "shows <%= singular_table_name %>" do
28
27
  get :show, id: <%= singular_table_name %>
29
- assert_response :success
28
+ value(response).must_be :success?
30
29
  end
31
30
 
32
31
  it "gets edit" do
33
32
  get :edit, id: <%= singular_table_name %>
34
- assert_response :success
33
+ value(response).must_be :success?
35
34
  end
36
35
 
37
36
  it "updates <%= singular_table_name %>" do
38
37
  put :update, id: <%= singular_table_name %>, <%= "#{singular_table_name}: { #{attributes_hash} }" %>
39
- assert_redirected_to <%= singular_table_name %>_path(assigns(:<%= singular_table_name %>))
38
+ must_redirect_to <%= singular_table_name %>_path(assigns(:<%= singular_table_name %>))
40
39
  end
41
40
 
42
41
  it "destroys <%= singular_table_name %>" do
43
- assert_difference('<%= class_name %>.count', -1) do
42
+ expect {
44
43
  delete :destroy, id: <%= singular_table_name %>
45
- end
44
+ }.must_change "<%= class_name %>.count", -1
46
45
 
47
- assert_redirected_to <%= index_helper %>_path
46
+ must_redirect_to <%= index_helper %>_path
48
47
  end
49
-
50
48
  end
51
49
  <% end -%>
@@ -2,7 +2,6 @@ require "test_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
4
  class <%= controller_class_name %>ControllerTest < ActionController::TestCase
5
-
6
5
  def <%= singular_table_name %>
7
6
  @<%= singular_table_name %> ||= <%= table_name %> :one
8
7
  end
@@ -19,7 +18,7 @@ class <%= controller_class_name %>ControllerTest < ActionController::TestCase
19
18
  end
20
19
 
21
20
  def test_create
22
- assert_difference('<%= class_name %>.count') do
21
+ assert_difference("<%= class_name %>.count") do
23
22
  post :create, <%= "#{singular_table_name}: { #{attributes_hash} }" %>
24
23
  end
25
24
 
@@ -42,7 +41,7 @@ class <%= controller_class_name %>ControllerTest < ActionController::TestCase
42
41
  end
43
42
 
44
43
  def test_destroy
45
- assert_difference('<%= class_name %>.count', -1) do
44
+ assert_difference("<%= class_name %>.count", -1) do
46
45
  delete :destroy, id: <%= singular_table_name %>
47
46
  end
48
47
 
@@ -75,6 +75,19 @@ class ActionView::TestCase
75
75
  end
76
76
  end
77
77
 
78
+ if defined? ActiveJob
79
+ class ActiveJob::TestCase
80
+ # Use AJ::TestCase for the base when describing a job
81
+ register_spec_type(self) do |desc|
82
+ desc < ActiveJob::Base if desc.is_a?(Class)
83
+ end
84
+ register_spec_type(/Job( ?Test)?\z/i, self)
85
+ register_spec_type(self) do |desc, *addl|
86
+ addl.include? :job
87
+ end
88
+ end
89
+ end
90
+
78
91
  if defined? ActionMailer
79
92
  require "action_mailer/test_helper"
80
93
  require "action_mailer/test_case"
@@ -84,9 +97,9 @@ if defined? ActionMailer
84
97
  desc < ActionMailer::Base if desc.is_a?(Class)
85
98
  end
86
99
  register_spec_type(/Mailer( ?Test)?\z/i, self)
87
- register_spec_type(self) do |desc, *addl|
88
- addl.include? :mailer
89
- end
100
+ register_spec_type(self) do |desc, *addl|
101
+ addl.include? :mailer
102
+ end
90
103
 
91
104
  # Resolve the mailer from the test name when using the spec DSL
92
105
  def self.determine_default_mailer(name)
@@ -528,6 +528,74 @@ class ActionController::TestCase
528
528
  # :method: refute_tag
529
529
  # :call-seq: refute_tag(*opts)
530
530
  alias :refute_tag :assert_no_tag
531
+
532
+ ##
533
+ # Simulate a GET request with the given parameters.
534
+ #
535
+ # - +action+: The controller action to call.
536
+ # - +params+: The hash with HTTP parameters that you want to pass. This may be
537
+ # +nil+.
538
+ # - +body+: The request body with a string that is appropriately encoded
539
+ # (<tt>application/x-www-form-urlencoded</tt> or
540
+ # <tt>multipart/form-data</tt>).
541
+ # - +session+: A hash of parameters to store in the session. This may be
542
+ # +nil+.
543
+ # - +flash+: A hash of parameters to store in the flash. This may be +nil+.
544
+ #
545
+ # You can also simulate POST, PATCH, PUT, DELETE, and HEAD requests with
546
+ # +post+, +patch+, +put+, +delete+, and +head+.
547
+ # Example sending parameters, session and setting a flash message:
548
+ #
549
+ # get :show,
550
+ # params: { id: 7 },
551
+ # session: { user_id: 1 },
552
+ # flash: { notice: 'This is a flash message' }
553
+ #
554
+ # Note that the request method is not verified. The different methods are
555
+ # available to make the tests more expressive.
556
+ #
557
+ # :method: get
558
+ # :call-seq: get(action, *args)
559
+
560
+ ##
561
+ # Simulate a POST request with the given parameters and set/volley the
562
+ # response.
563
+ # See +get+ for more details.
564
+ #
565
+ # :method: post
566
+ # :call-seq: post(action, *args)
567
+
568
+ ##
569
+ # Simulate a PATCH request with the given parameters and set/volley the
570
+ # response.
571
+ # See +get+ for more details.
572
+ #
573
+ # :method: patch
574
+ # :call-seq: patch(action, *args)
575
+
576
+ ##
577
+ # Simulate a PUT request with the given parameters and set/volley the
578
+ # response.
579
+ # See +get+ for more details.
580
+ #
581
+ # :method: put
582
+ # :call-seq: put(action, *args)
583
+
584
+ ##
585
+ # Simulate a DELETE request with the given parameters and set/volley the
586
+ # response.
587
+ # See +get+ for more details.
588
+ #
589
+ # :method: delete
590
+ # :call-seq: delete(action, *args)
591
+
592
+ ##
593
+ # Simulate a HEAD request with the given parameters and set/volley the
594
+ # response.
595
+ # See +get+ for more details.
596
+ #
597
+ # :method: head
598
+ # :call-seq: head(action, *args)
531
599
  end
532
600
 
533
601
  class ActionView::TestCase
@@ -1592,4 +1660,158 @@ class ActionController::TestCase
1592
1660
  # :method: refute_tag
1593
1661
  # :call-seq: refute_tag(*opts)
1594
1662
  alias :refute_tag :assert_no_tag
1595
- end
1663
+ end
1664
+
1665
+ if defined? ActiveJob
1666
+ class ActiveJob::TestCase
1667
+ # Asserts that the number of enqueued jobs matches the given number.
1668
+ #
1669
+ # def test_jobs
1670
+ # assert_enqueued_jobs 0
1671
+ # HelloJob.perform_later('david')
1672
+ # assert_enqueued_jobs 1
1673
+ # HelloJob.perform_later('abdelkader')
1674
+ # assert_enqueued_jobs 2
1675
+ # end
1676
+ #
1677
+ # If a block is passed, that block should cause the specified number of
1678
+ # jobs to be enqueued.
1679
+ #
1680
+ # def test_jobs_again
1681
+ # assert_enqueued_jobs 1 do
1682
+ # HelloJob.perform_later('cristian')
1683
+ # end
1684
+ #
1685
+ # assert_enqueued_jobs 2 do
1686
+ # HelloJob.perform_later('aaron')
1687
+ # HelloJob.perform_later('rafael')
1688
+ # end
1689
+ # end
1690
+ #
1691
+ # See also Minitest::Rails::Expectations#must_enqueue_jobs
1692
+ #
1693
+ # :method: assert_enqueued_jobs
1694
+ # :call-seq: assert_enqueued_jobs(number)
1695
+
1696
+ ##
1697
+ # Asserts that no jobs have been enqueued.
1698
+ #
1699
+ # def test_jobs
1700
+ # assert_no_enqueued_jobs
1701
+ # HelloJob.perform_later('jeremy')
1702
+ # assert_enqueued_jobs 1
1703
+ # end
1704
+ #
1705
+ # If a block is passed, that block should not cause any job to be enqueued.
1706
+ #
1707
+ # def test_jobs_again
1708
+ # assert_no_enqueued_jobs do
1709
+ # # No job should be enqueued from this block
1710
+ # end
1711
+ # end
1712
+ #
1713
+ # Note: This assertion is simply a shortcut for:
1714
+ #
1715
+ # assert_enqueued_jobs 0, &block
1716
+ #
1717
+ # See also Minitest::Rails::Expectations#wont_enqueue_jobs
1718
+ #
1719
+ # :method: assert_no_enqueued_jobs
1720
+ # :call-seq: assert_no_enqueued_jobs(number)
1721
+
1722
+ ##
1723
+ # Asserts that the number of performed jobs matches the given number.
1724
+ # If no block is passed, <tt>perform_enqueued_jobs</tt>d
1725
+ # must be called around the job call.
1726
+ #
1727
+ # def test_jobs
1728
+ # assert_performed_jobs 0
1729
+ #
1730
+ # perform_enqueued_jobs do
1731
+ # HelloJob.perform_later('xavier')
1732
+ # end
1733
+ # assert_performed_jobs 1
1734
+ #
1735
+ # perform_enqueued_jobs do
1736
+ # HelloJob.perform_later('yves')
1737
+ # assert_performed_jobs 2
1738
+ # end
1739
+ # end
1740
+ #
1741
+ # If a block is passed, that block should cause the specified number of
1742
+ # jobs to be performed.
1743
+ #
1744
+ # def test_jobs_again
1745
+ # assert_performed_jobs 1 do
1746
+ # HelloJob.perform_later('robin')
1747
+ # end
1748
+ #
1749
+ # assert_performed_jobs 2 do
1750
+ # HelloJob.perform_later('carlos')
1751
+ # HelloJob.perform_later('sean')
1752
+ # end
1753
+ # end
1754
+ #
1755
+ # See also Minitest::Rails::Expectations#must_perform_jobs
1756
+ #
1757
+ # :method: assert_performed_jobs
1758
+ # :call-seq: assert_performed_jobs(number)
1759
+
1760
+ ##
1761
+ # Asserts that no jobs have been performed.
1762
+ #
1763
+ # def test_jobs
1764
+ # assert_no_performed_jobs
1765
+ #
1766
+ # perform_enqueued_jobs do
1767
+ # HelloJob.perform_later('matthew')
1768
+ # assert_performed_jobs 1
1769
+ # end
1770
+ # end
1771
+ #
1772
+ # If a block is passed, that block should not cause any job to be performed.
1773
+ #
1774
+ # def test_jobs_again
1775
+ # assert_no_performed_jobs do
1776
+ # # No job should be performed from this block
1777
+ # end
1778
+ # end
1779
+ #
1780
+ # Note: This assertion is simply a shortcut for:
1781
+ #
1782
+ # assert_performed_jobs 0, &block
1783
+ #
1784
+ # See also Minitest::Rails::Expectations#wont_perform_jobs
1785
+ #
1786
+ # :method: assert_no_performed_jobs
1787
+ # :call-seq: assert_no_performed_jobs(number)
1788
+
1789
+ ##
1790
+ # Asserts that the job passed in the block has been enqueued with the given arguments.
1791
+ #
1792
+ # def test_assert_enqueued_with
1793
+ # assert_enqueued_with(job: MyJob, args: [1,2,3], queue: 'low') do
1794
+ # MyJob.perform_later(1,2,3)
1795
+ # end
1796
+ # end
1797
+ #
1798
+ # See also Minitest::Rails::Expectations#must_enqueue_with
1799
+ #
1800
+ # :method: assert_enqueued_with
1801
+ # :call-seq: assert_enqueued_with(args)
1802
+
1803
+ ##
1804
+ # Asserts that the job passed in the block has been performed with the given arguments.
1805
+ #
1806
+ # def test_assert_performed_with
1807
+ # assert_performed_with(job: MyJob, args: [1,2,3], queue: 'high') do
1808
+ # MyJob.perform_later(1,2,3)
1809
+ # end
1810
+ # end
1811
+ #
1812
+ # See also Minitest::Rails::Expectations#must_perform_with
1813
+ #
1814
+ # :method: assert_performed_with
1815
+ # :call-seq: assert_performed_with(args)
1816
+ end
1817
+ end