minitest-rails 5.0.0 → 5.1.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
  SHA256:
3
- metadata.gz: 921cfaa469ddecc9a13aa20c02dc2fd9bffa5eafa5bf605713604d95b0e1b9b1
4
- data.tar.gz: c431d89abcec70990467b4f756f2fdbf2d057df7c9e1ebb717bb08100e3bc936
3
+ metadata.gz: b1104f99ae200b725d2b60309b6ee1868f2bf15075386cc16073f39e24d3aaf3
4
+ data.tar.gz: c4bda57b55878bcf5fb0a057ca7f7f888b60108eb4ae47d4b1db1098b5ae6d63
5
5
  SHA512:
6
- metadata.gz: bff8982d4743945a7795de1db69a27e3335fa4406b3a83d16ad6b6654005efdd6412982c093d3d7cfab366b045d03def59e00d411aa42717e85cf89cf0783db6
7
- data.tar.gz: 6960f3757941914a3667c3f6e588305c3622f05a646216c4da5904ee4794f549fe32caf4e3d088e9ae33fe41ddc7d8a7d4b84fd6cb5cf0a7e7b04d20fa59a336
6
+ metadata.gz: f8ba06eab31eeabe204b9fb51e87594d33dd10964f95952510b04dee8089c38b883cd19979d2d6604e296a19a4d9afbec3aee2da33332ead155416465a628288
7
+ data.tar.gz: 2d0c87af3c79e3774c1467b9811660ed0c6eef5101f2805d0b93fc90486fce1a2bb8610496db696e0b78dff7a4cb512a684817c7173c6575908603809349b3e9
@@ -1,5 +1,5 @@
1
1
  # Changes
2
2
 
3
- ### 5.0.0 / upcoming...
3
+ ### 5.1.0 / upcoming...
4
4
 
5
5
  * ...
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # minitest-rails
2
2
 
3
- Minitest integration for Rails 5.0
3
+ Minitest integration for Rails 5.1
4
4
 
5
5
  [![Build Status](https://secure.travis-ci.org/blowmage/minitest-rails.png)](http://travis-ci.org/blowmage/minitest-rails)
6
6
  [![Code Climate](https://codeclimate.com/github/blowmage/minitest-rails.png)](https://codeclimate.com/github/blowmage/minitest-rails)
@@ -21,11 +21,11 @@ Create a new rails app:
21
21
 
22
22
  ### Update Gemfile
23
23
 
24
- This version is for Rails 5.0 applications. Update your application to use the
24
+ This version is for Rails 5.1 applications. Update your application to use the
25
25
  gem by adding the following to your Gemfile:
26
26
 
27
27
  ```ruby
28
- gem "minitest-rails", "~> 5.0.0"
28
+ gem "minitest-rails", "~> 5.1.0"
29
29
  ```
30
30
 
31
31
  ### Installing
@@ -26,6 +26,7 @@ module Minitest
26
26
  empty_directory_with_keep_file "test/helpers"
27
27
  empty_directory_with_keep_file "test/integration"
28
28
 
29
+ template "test/application_system_test_case.rb"
29
30
  template "test/test_helper.rb"
30
31
  end
31
32
  end
@@ -0,0 +1,10 @@
1
+ require "test_helper"
2
+ require "minitest/rails/capybara"
3
+
4
+ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
5
+ driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
6
+
7
+ register_spec_type(self) do |desc, *addl|
8
+ addl.include? :system
9
+ end
10
+ end
@@ -13,12 +13,19 @@ module Minitest # :nodoc:
13
13
  class_option :api, type: :boolean,
14
14
  desc: "Generates API functional tests"
15
15
 
16
+ class_option :system_tests, type: :string,
17
+ desc: "Skip system test files"
18
+
16
19
  argument :attributes, type: :array, default: [], banner: "field:type field:type"
17
20
 
18
21
  def create_test_files
19
22
  template_file = options.api? ? "api_functional_#{test_file_type}.rb" : "functional_#{test_file_type}.rb"
20
23
  template template_file,
21
24
  File.join("test/controllers", controller_class_path, "#{controller_file_name}_controller_test.rb")
25
+
26
+ if !options.api? && options[:system_tests]
27
+ template "system_#{test_file_type}.rb", File.join("test/system", class_path, "#{file_name.pluralize}_test.rb")
28
+ end
22
29
  end
23
30
 
24
31
  def fixture_name
@@ -0,0 +1,55 @@
1
+ require "application_system_test_case"
2
+
3
+ <% module_namespacing do -%>
4
+ describe "<%= class_name.pluralize %>", :system do
5
+ let(:<%= singular_table_name %>) { <%= fixture_name %>(:one) }
6
+
7
+ it "visiting the index" do
8
+ visit <%= plural_table_name %>_url
9
+ assert_selector "h1", text: "<%= class_name.pluralize.titleize %>"
10
+ end
11
+
12
+ it "creating a <%= human_name %>" do
13
+ visit <%= plural_table_name %>_url
14
+ click_on "New <%= class_name.titleize %>"
15
+
16
+ <%- attributes_hash.each do |attr, value| -%>
17
+ <%- if boolean?(attr) -%>
18
+ check "<%= attr.humanize %>" if <%= value %>
19
+ <%- else -%>
20
+ fill_in "<%= attr.humanize %>", with: <%= value %>
21
+ <%- end -%>
22
+ <%- end -%>
23
+ click_on "Create <%= human_name %>"
24
+
25
+ assert_text "<%= human_name %> was successfully created"
26
+ click_on "Back"
27
+ end
28
+
29
+ it "updating a <%= human_name %>" do
30
+ visit <%= plural_table_name %>_url
31
+ click_on "Edit", match: :first
32
+
33
+ <%- attributes_hash.each do |attr, value| -%>
34
+ <%- if boolean?(attr) -%>
35
+ check "<%= attr.humanize %>" if <%= value %>
36
+ <%- else -%>
37
+ fill_in "<%= attr.humanize %>", with: <%= value %>
38
+ <%- end -%>
39
+ <%- end -%>
40
+ click_on "Update <%= human_name %>"
41
+
42
+ assert_text "<%= human_name %> was successfully updated"
43
+ click_on "Back"
44
+ end
45
+
46
+ it "destroying a <%= human_name %>" do
47
+ visit <%= plural_table_name %>_url
48
+ page.accept_confirm do
49
+ click_on "Destroy", match: :first
50
+ end
51
+
52
+ assert_text "<%= human_name %> was successfully destroyed"
53
+ end
54
+ end
55
+ <% end -%>
@@ -0,0 +1,57 @@
1
+ require "application_system_test_case"
2
+
3
+ <% module_namespacing do -%>
4
+ class <%= class_name.pluralize %>Test < ApplicationSystemTestCase
5
+ setup do
6
+ @<%= singular_table_name %> = <%= fixture_name %>(:one)
7
+ end
8
+
9
+ def test_visiting_index
10
+ visit <%= plural_table_name %>_url
11
+ assert_selector "h1", text: "<%= class_name.pluralize.titleize %>"
12
+ end
13
+
14
+ def test_creating_<%= human_name %>
15
+ visit <%= plural_table_name %>_url
16
+ click_on "New <%= class_name.titleize %>"
17
+
18
+ <%- attributes_hash.each do |attr, value| -%>
19
+ <%- if boolean?(attr) -%>
20
+ check "<%= attr.humanize %>" if <%= value %>
21
+ <%- else -%>
22
+ fill_in "<%= attr.humanize %>", with: <%= value %>
23
+ <%- end -%>
24
+ <%- end -%>
25
+ click_on "Create <%= human_name %>"
26
+
27
+ assert_text "<%= human_name %> was successfully created"
28
+ click_on "Back"
29
+ end
30
+
31
+ def test_updating_<%= human_name %>
32
+ visit <%= plural_table_name %>_url
33
+ click_on "Edit", match: :first
34
+
35
+ <%- attributes_hash.each do |attr, value| -%>
36
+ <%- if boolean?(attr) -%>
37
+ check "<%= attr.humanize %>" if <%= value %>
38
+ <%- else -%>
39
+ fill_in "<%= attr.humanize %>", with: <%= value %>
40
+ <%- end -%>
41
+ <%- end -%>
42
+ click_on "Update <%= human_name %>"
43
+
44
+ assert_text "<%= human_name %> was successfully updated"
45
+ click_on "Back"
46
+ end
47
+
48
+ def test_destroying_<%= human_name %>
49
+ visit <%= plural_table_name %>_url
50
+ page.accept_confirm do
51
+ click_on "Destroy", match: :first
52
+ end
53
+
54
+ assert_text "<%= human_name %> was successfully destroyed"
55
+ end
56
+ end
57
+ <% end -%>
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "generators/minitest"
4
+
5
+ module Minitest # :nodoc:
6
+ module Generators # :nodoc:
7
+ class SystemGenerator < Base # :nodoc:
8
+ check_class_collision suffix: "Test"
9
+
10
+ def create_test_files
11
+ unless File.exist?(File.join("test/application_system_test_case.rb"))
12
+ template "application_system_test_case.rb", File.join("test", "application_system_test_case.rb")
13
+ end
14
+
15
+ template "system_#{test_file_type}.rb", File.join("test/system", class_path, "#{file_name.pluralize}_test.rb")
16
+ end
17
+
18
+ private
19
+
20
+ def file_name
21
+ @_file_name ||= super.sub(/_test\z/i, "")
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,10 @@
1
+ require "test_helper"
2
+ require "minitest/rails/capybara"
3
+
4
+ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
5
+ driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
6
+
7
+ register_spec_type(self) do |desc, *addl|
8
+ addl.include? :system
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ require "application_system_test_case"
2
+
3
+ class <%= class_name.pluralize %>Test < ApplicationSystemTestCase
4
+ # test "visiting the index" do
5
+ # visit <%= plural_table_name %>_url
6
+ #
7
+ # assert_selector "h1", text: "<%= class_name %>"
8
+ # end
9
+ end
@@ -0,0 +1,9 @@
1
+ require "application_system_test_case"
2
+
3
+ class <%= class_name.pluralize %>Test < ApplicationSystemTestCase
4
+ # test "visiting the index" do
5
+ # visit <%= plural_table_name %>_url
6
+ #
7
+ # assert_selector "h1", text: "<%= class_name %>"
8
+ # end
9
+ end
@@ -25,7 +25,7 @@ class ActionMailer::TestCase
25
25
  # end
26
26
  #
27
27
  # See also Minitest::Rails::Expectations::ActionMailer#must_have_emails
28
- # See https://api.rubyonrails.org/v5.0/classes/ActionMailer/TestHelper.html#method-i-assert_emails
28
+ # See https://api.rubyonrails.org/v5.1/classes/ActionMailer/TestHelper.html#method-i-assert_emails
29
29
  #
30
30
  # :method: assert_emails
31
31
  # :call-seq: assert_emails(number, &block)
@@ -51,7 +51,7 @@ class ActionMailer::TestCase
51
51
  # assert_emails 0, &block
52
52
  #
53
53
  # See also Minitest::Rails::Expectations::ActionMailer#wont_have_emails
54
- # See https://api.rubyonrails.org/v5.0/classes/ActionMailer/TestHelper.html#method-i-assert_no_emails
54
+ # See https://api.rubyonrails.org/v5.1/classes/ActionMailer/TestHelper.html#method-i-assert_no_emails
55
55
  #
56
56
  # :method: refute_emails
57
57
  # :call-seq: refute_emails(&block)
@@ -84,7 +84,7 @@ class ActionMailer::TestCase
84
84
  # end
85
85
  #
86
86
  # See also Minitest::Rails::Expectations::ActionMailer#must_have_enqueued_emails
87
- # See https://api.rubyonrails.org/v5.0/classes/ActionMailer/TestHelper.html#method-i-assert_enqueued_emails
87
+ # See https://api.rubyonrails.org/v5.1/classes/ActionMailer/TestHelper.html#method-i-assert_enqueued_emails
88
88
  #
89
89
  # :method: assert_enqueued_emails
90
90
  # :call-seq: assert_enqueued_emails(number, &block)
@@ -107,7 +107,7 @@ class ActionMailer::TestCase
107
107
  # end
108
108
  #
109
109
  # See also Minitest::Rails::Expectations::ActionMailer#wont_have_enqueued_emails
110
- # See https://api.rubyonrails.org/v5.0/classes/ActionMailer/TestHelper.html#method-i-assert_no_enqueued_emails
110
+ # See https://api.rubyonrails.org/v5.1/classes/ActionMailer/TestHelper.html#method-i-assert_no_enqueued_emails
111
111
  #
112
112
  # :method: refute_enqueued_emails
113
113
  # :call-seq: refute_enqueued_emails(&block)
@@ -1,4 +1,32 @@
1
1
  class ActiveSupport::TestCase
2
+ ##
3
+ # Assertion that the result of evaluating an expression is changed before and
4
+ # after invoking the passed in block.
5
+ #
6
+ # assert_changes "Status.all_good?" do
7
+ # post :create, params: { status: { ok: false } }
8
+ # end
9
+ #
10
+ # See also Minitest::Rails::Expectations::ActiveSupport#must_change
11
+ # See https://api.rubyonrails.org/v5.1/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_changes
12
+ #
13
+ # :method: assert_changes
14
+ # :call-seq: assert_changes(expression, message = nil, from: UNTRACKED, to: UNTRACKED, &block)
15
+
16
+ ##
17
+ # Assertion that the result of evaluating an expression is not changed before
18
+ # and after invoking the passed in block.
19
+ #
20
+ # refute_changes "Status.all_good?" do
21
+ # post :create, params: { status: { ok: true } }
22
+ # end
23
+ #
24
+ # See also Minitest::Rails::Expectations::ActiveSupport#wont_change
25
+ # See https://api.rubyonrails.org/v5.1/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_no_changes
26
+ #
27
+ # :args: expression, message = nil, &block
28
+ alias refute_changes assert_no_changes
29
+
2
30
  ##
3
31
  # Test numeric difference between the return value of an expression as a
4
32
  # result of what is evaluated in the yielded block.
@@ -8,7 +36,7 @@ class ActiveSupport::TestCase
8
36
  # end
9
37
  #
10
38
  # See also Minitest::Rails::Expectations::ActiveSupport#must_change
11
- # See https://api.rubyonrails.org/v5.0/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_difference
39
+ # See https://api.rubyonrails.org/v5.1/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_difference
12
40
  #
13
41
  # :method: assert_difference
14
42
  # :call-seq: assert_difference(expression, *args, &block)
@@ -22,7 +50,7 @@ class ActiveSupport::TestCase
22
50
  # end
23
51
  #
24
52
  # See also Minitest::Rails::Expectations::ActiveSupport#wont_change
25
- # See https://api.rubyonrails.org/v5.0/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_no_difference
53
+ # See https://api.rubyonrails.org/v5.1/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_no_difference
26
54
  #
27
55
  # :args: expression, message = nil, &block
28
56
  alias refute_difference assert_no_difference
@@ -0,0 +1,16 @@
1
+ require "capybara/minitest"
2
+ require "capybara/minitest/spec"
3
+
4
+ class ActionDispatch::SystemTestCase
5
+ # Enable Capybara's spec DSL
6
+ class << self
7
+ alias background before
8
+ alias scenario it
9
+ alias given let
10
+ end
11
+ end
12
+
13
+ module Kernel # :nodoc:
14
+ # Enable Capybara's spec DSL
15
+ alias feature describe
16
+ end
@@ -30,7 +30,7 @@ module Minitest
30
30
  # end
31
31
  #
32
32
  # See also ActionMailer::TestClass#assert_emails
33
- # See https://api.rubyonrails.org/v5.0/classes/ActionMailer/TestHelper.html#method-i-assert_emails
33
+ # See https://api.rubyonrails.org/v5.1/classes/ActionMailer/TestHelper.html#method-i-assert_emails
34
34
  #
35
35
  # :method: must_have_emails
36
36
  # :call-seq: must_have_emails(number, &block)
@@ -56,7 +56,7 @@ module Minitest
56
56
  # must_have_emails 0, &block
57
57
  #
58
58
  # See also ActionMailer::TestClass#wont_have_emails
59
- # See https://api.rubyonrails.org/v5.0/classes/ActionMailer/TestHelper.html#method-i-assert_no_emails
59
+ # See https://api.rubyonrails.org/v5.1/classes/ActionMailer/TestHelper.html#method-i-assert_no_emails
60
60
  #
61
61
  # :method: wont_have_emails
62
62
  # :call-seq: wont_have_emails(&block)
@@ -88,7 +88,7 @@ module Minitest
88
88
  # end
89
89
  #
90
90
  # See also ActionMailer::TestClass#assert_enqueued_emails
91
- # See https://api.rubyonrails.org/v5.0/classes/ActionMailer/TestHelper.html#method-i-assert_enqueued_emails
91
+ # See https://api.rubyonrails.org/v5.1/classes/ActionMailer/TestHelper.html#method-i-assert_enqueued_emails
92
92
  #
93
93
  # :method: must_have_enqueued_emails
94
94
  # :call-seq: must_have_enqueued_emails(number, &block)
@@ -111,7 +111,7 @@ module Minitest
111
111
  # end
112
112
  #
113
113
  # See also ActionMailer::TestClass#assert_no_enqueued_emails
114
- # See https://api.rubyonrails.org/v5.0/classes/ActionMailer/TestHelper.html#method-i-assert_no_enqueued_emails
114
+ # See https://api.rubyonrails.org/v5.1/classes/ActionMailer/TestHelper.html#method-i-assert_no_enqueued_emails
115
115
  #
116
116
  # :method: wont_have_enqueued_emails
117
117
  # :call-seq: wont_have_enqueued_emails(&block)
@@ -2,6 +2,37 @@ module Minitest
2
2
  module Rails
3
3
  module Expectations
4
4
  module ActiveSupport
5
+ ##
6
+ # Assertion that the result of evaluating an expression is changed before and
7
+ # after invoking the passed in block.
8
+ #
9
+ # value { User.create password: "valid" }.must_change "User.count"
10
+ # value { 3.times do
11
+ # User.create password: "valid"
12
+ # end }.must_change "User.count", from: 5, to: 8
13
+ #
14
+ # See also ActiveSupport::TestCase#assert_difference
15
+ # See https://api.rubyonrails.org/v5.1/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_changes
16
+ #
17
+ # :method: must_change
18
+ # :args: expression, from: UNTRACKED, to: UNTRACKED
19
+ infect_an_assertion :assert_changes, :must_change, :block
20
+
21
+ ##
22
+ # Assertion that the result of evaluating an expression is not changed before
23
+ # and after invoking the passed in block.
24
+ #
25
+ # refute_changes "Status.all_good?" do
26
+ # post :create, params: { status: { ok: true } }
27
+ # end
28
+ #
29
+ # See also ActiveSupport::TestCase#assert_difference
30
+ # See https://api.rubyonrails.org/v5.1/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_no_changes
31
+ #
32
+ # :method: wont_change
33
+ # :args: expression
34
+ infect_an_assertion :refute_changes, :wont_change, :block
35
+
5
36
  ##
6
37
  # Test numeric difference between the return value of an expression as a
7
38
  # result of what is evaluated.
@@ -12,7 +43,7 @@ module Minitest
12
43
  # end }.must_differ "User.count", 3
13
44
  #
14
45
  # See also ActiveSupport::TestCase#assert_difference
15
- # See https://api.rubyonrails.org/v5.0/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_difference
46
+ # See https://api.rubyonrails.org/v5.1/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_difference
16
47
  #
17
48
  # :method: must_differ
18
49
  # :args: expression, *args
@@ -25,7 +56,7 @@ module Minitest
25
56
  # value { User.new }.wont_differ "User.count"
26
57
  #
27
58
  # See also ActiveSupport::TestCase#refute_difference
28
- # See https://api.rubyonrails.org/v5.0/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_no_difference
59
+ # See https://api.rubyonrails.org/v5.1/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_no_difference
29
60
  #
30
61
  # :method: wont_differ
31
62
  # :args: expression
@@ -1,5 +1,5 @@
1
1
  module Minitest
2
2
  module Rails
3
- VERSION = "5.0.0".freeze
3
+ VERSION = "5.1.0".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Moore
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 5.0.0
33
+ version: 5.1.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 5.0.0
40
+ version: 5.1.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest-autotest
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -128,6 +128,7 @@ files:
128
128
  - lib/generators/minitest/generator/templates/generator_test.rb.tt
129
129
  - lib/generators/minitest/helper/helper_generator.rb
130
130
  - lib/generators/minitest/install/install_generator.rb
131
+ - lib/generators/minitest/install/templates/test/application_system_test_case.rb.tt
131
132
  - lib/generators/minitest/install/templates/test/test_helper.rb.tt
132
133
  - lib/generators/minitest/integration/integration_generator.rb
133
134
  - lib/generators/minitest/integration/templates/integration_spec.rb.tt
@@ -151,6 +152,12 @@ files:
151
152
  - lib/generators/minitest/scaffold/templates/api_functional_test.rb.tt
152
153
  - lib/generators/minitest/scaffold/templates/functional_spec.rb.tt
153
154
  - lib/generators/minitest/scaffold/templates/functional_test.rb.tt
155
+ - lib/generators/minitest/scaffold/templates/system_spec.rb.tt
156
+ - lib/generators/minitest/scaffold/templates/system_test.rb.tt
157
+ - lib/generators/minitest/system/system_generator.rb
158
+ - lib/generators/minitest/system/templates/application_system_test_case.rb.tt
159
+ - lib/generators/minitest/system/templates/system_spec.rb.tt
160
+ - lib/generators/minitest/system/templates/system_test.rb.tt
154
161
  - lib/minitest-rails.rb
155
162
  - lib/minitest/rails.rb
156
163
  - lib/minitest/rails/assertions.rb
@@ -159,6 +166,7 @@ files:
159
166
  - lib/minitest/rails/assertions/action_view.rb
160
167
  - lib/minitest/rails/assertions/active_job.rb
161
168
  - lib/minitest/rails/assertions/active_support.rb
169
+ - lib/minitest/rails/capybara.rb
162
170
  - lib/minitest/rails/expectations.rb
163
171
  - lib/minitest/rails/expectations/action_dispatch.rb
164
172
  - lib/minitest/rails/expectations/action_mailer.rb