minitest-rails 1.0.1 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -10
  3. data/CHANGELOG.rdoc +0 -24
  4. data/Gemfile +1 -1
  5. data/LICENSE +1 -1
  6. data/Manifest.txt +31 -31
  7. data/README.rdoc +15 -17
  8. data/Rakefile +5 -6
  9. data/gemfiles/{4.0.gemfile → 4.1.gemfile} +2 -1
  10. data/lib/generators/minitest/controller/controller_generator.rb +20 -0
  11. data/lib/generators/{mini_test → minitest}/controller/templates/controller_spec.rb +0 -0
  12. data/lib/generators/{mini_test → minitest}/controller/templates/controller_test.rb +0 -0
  13. data/lib/generators/minitest/generator/generator_generator.rb +32 -0
  14. data/lib/generators/minitest/generator/templates/generator_spec.rb +14 -0
  15. data/lib/generators/minitest/generator/templates/generator_test.rb +15 -0
  16. data/lib/generators/minitest/helper/helper_generator.rb +19 -0
  17. data/lib/generators/{mini_test → minitest}/helper/templates/helper_spec.rb +0 -2
  18. data/lib/generators/{mini_test → minitest}/helper/templates/helper_test.rb +0 -0
  19. data/lib/generators/{mini_test → minitest}/install/install_generator.rb +2 -2
  20. data/lib/generators/{mini_test → minitest}/install/templates/test_helper.rb +0 -0
  21. data/lib/generators/minitest/integration/integration_generator.rb +19 -0
  22. data/lib/generators/{mini_test → minitest}/integration/templates/integration_spec.rb +0 -0
  23. data/lib/generators/{mini_test → minitest}/integration/templates/integration_test.rb +0 -0
  24. data/lib/generators/minitest/mailer/mailer_generator.rb +27 -0
  25. data/lib/generators/{mini_test → minitest}/mailer/templates/mailer_spec.rb +0 -0
  26. data/lib/generators/{mini_test → minitest}/mailer/templates/mailer_test.rb +0 -0
  27. data/lib/generators/minitest/mailer/templates/preview.rb +13 -0
  28. data/lib/generators/minitest/model/model_generator.rb +42 -0
  29. data/lib/generators/{mini_test → minitest}/model/templates/fixtures.yml +0 -0
  30. data/lib/generators/{mini_test → minitest}/model/templates/model_spec.rb +0 -0
  31. data/lib/generators/{mini_test → minitest}/model/templates/model_test.rb +0 -0
  32. data/lib/generators/{mini_test → minitest}/route/route_generator.rb +4 -4
  33. data/lib/generators/{mini_test → minitest}/route/templates/route_spec.rb +1 -1
  34. data/lib/generators/{mini_test → minitest}/route/templates/route_test.rb +1 -1
  35. data/lib/generators/minitest/scaffold/scaffold_generator.rb +38 -0
  36. data/lib/generators/{mini_test → minitest}/scaffold/templates/controller_spec.rb +4 -4
  37. data/lib/generators/{mini_test → minitest}/scaffold/templates/controller_test.rb +4 -4
  38. data/lib/generators/minitest.rb +14 -0
  39. data/lib/minitest/rails/assertions.rb +54 -270
  40. data/lib/minitest/rails/constant_lookup.rb +1 -1
  41. data/lib/minitest/rails/expectations.rb +2 -90
  42. data/lib/minitest/rails/railtie.rb +4 -4
  43. data/lib/minitest/rails/tasks/minitest.rake +20 -20
  44. data/lib/minitest/rails/tasks/sub_test_task.rb +1 -1
  45. data/lib/minitest/rails/testing.rb +2 -2
  46. data/lib/minitest/rails/version.rb +2 -2
  47. data/lib/minitest/rails.rb +38 -14
  48. data/minitest-rails.gemspec +13 -16
  49. data/tasks/test.rake +4 -31
  50. data/test/generators/test_controller_generator.rb +6 -6
  51. data/test/generators/test_generator_generator.rb +58 -0
  52. data/test/generators/test_helper_generator.rb +5 -5
  53. data/test/generators/test_install_generator.rb +3 -3
  54. data/test/generators/test_mailer_generator.rb +5 -5
  55. data/test/generators/test_model_generator.rb +9 -9
  56. data/test/generators/test_route_generator.rb +3 -3
  57. data/test/generators/test_scaffold_generator.rb +3 -3
  58. data/test/helper.rb +4 -1
  59. data/test/rails/action_controller/test_spec_type.rb +19 -14
  60. data/test/rails/action_dispatch/test_spec_type.rb +32 -29
  61. data/test/rails/action_mailer/test_spec_type.rb +19 -14
  62. data/test/rails/action_view/test_spec_type.rb +24 -18
  63. data/test/rails/active_support/test_assertions.rb +0 -28
  64. data/test/rails/active_support/test_expectations.rb +0 -28
  65. data/test/rails/active_support/test_spec_type.rb +9 -5
  66. data/test/rails/generators/test_spec_type.rb +13 -14
  67. data/test/test_sanity.rb +2 -2
  68. metadata +48 -61
  69. data/gemfiles/3.0.gemfile +0 -5
  70. data/gemfiles/3.1.gemfile +0 -5
  71. data/gemfiles/3.2.gemfile +0 -5
  72. data/gemfiles/minitest_tu_shim.rb +0 -4
  73. data/lib/generators/mini_test/controller/controller_generator.rb +0 -19
  74. data/lib/generators/mini_test/helper/helper_generator.rb +0 -17
  75. data/lib/generators/mini_test/integration/integration_generator.rb +0 -17
  76. data/lib/generators/mini_test/mailer/mailer_generator.rb +0 -19
  77. data/lib/generators/mini_test/model/model_generator.rb +0 -28
  78. data/lib/generators/mini_test/scaffold/scaffold_generator.rb +0 -42
  79. data/lib/generators/mini_test.rb +0 -42
  80. data/lib/minitest/rails/generators.rb +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d0e154d2407f4471ee927d30a1e5bdc7cd7a45d
4
- data.tar.gz: 1999eb1058b0131d1a9e6ff88ce66df61d65724e
3
+ metadata.gz: 543f2ffff937a22e784c7a03b5967fd727e70339
4
+ data.tar.gz: ad2b3ab73a693afb6d2fb8be571fd5e7eb0eff76
5
5
  SHA512:
6
- metadata.gz: 0d1d9fd36b7a54fb636a86967c5c928e2085b87750cf12a1595e4d3223ca4dbbbbeec7391f90ea5c78a5c0d1f3e8fa4616719b4587d19041b769650247a1bf25
7
- data.tar.gz: b6db1bd9f8bad5f998a2d78f194c9ca9b2c29e26596c3e8edcb5f7ea153ad140a5310ac258aa9640de72a776a88de741e79c9745d7901abc2782824db15a82c5
6
+ metadata.gz: 3a4951af77f19642c0b6a43f9fc9069ca1f68ccc1c2b34698b00e7bd1c920f62f3473dc2c85f5503057d08ededbfd919980879af76abefc35d39b70a48918fc8
7
+ data.tar.gz: 23bffd3475c5e31fc5e9adef9582ff9abcf2521f67849f17ede001ca7a4afc0302d7d4deb2d5ef144949b8fd69bba36a96946283deb654f813223fe0cd588347
data/.travis.yml CHANGED
@@ -2,7 +2,6 @@
2
2
  before_install:
3
3
  - gem update --system
4
4
  - gem --version
5
- - ruby gemfiles/minitest_tu_shim.rb
6
5
  language: ruby
7
6
  notifications:
8
7
  email:
@@ -12,13 +11,5 @@ rvm:
12
11
  - 2.1.0
13
12
  - 2.0.0
14
13
  - 1.9.3
15
- - 1.8.7
16
14
  env:
17
- - "RAILS_VERSION=4.0"
18
- - "RAILS_VERSION=3.2"
19
- - "RAILS_VERSION=3.1"
20
- - "RAILS_VERSION=3.0"
21
- matrix:
22
- exclude:
23
- - rvm: 1.8.7
24
- env: "RAILS_VERSION=4.0"
15
+ - "RAILS_VERSION=4.1"
data/CHANGELOG.rdoc CHANGED
@@ -1,27 +1,3 @@
1
- === 1.0.1 / 2014-04-15
2
-
3
- * Add missing module_namespacing to Helper spec
4
-
5
- https://github.com/blowmage/minitest-rails/compare/v1.0.0...v1.0.1
6
-
7
- === 1.0.0 / 2014-04-14
8
-
9
- Yay! A 1.0.0 release, finally!
10
-
11
- * New rake tasks
12
- * rake minitest:quick - Runs default tests without DB prep
13
- * rake minitest:all - Runs all test
14
- * rake minitest:all:quick - Runs all tests without DB prep
15
- * Add 'test' rake tasks if not already defined
16
- * Set the MT_RAILS_NO_AUTORUN flag to stop autorun from being called
17
- * Useful for integrating with zeus or other app loaders
18
- * Support Minitest 5's API
19
- * Allow use of Minitest::Test instead of MiniTest::Unit::TestCase
20
- * Add AS::TC assertions and expectations
21
- * Add MT_RAILS_NO_AUTORUN flag
22
-
23
- https://github.com/blowmage/minitest-rails/compare/v0.9.2...v1.0.0
24
-
25
1
  === 0.9.2 / 2013-04-05
26
2
 
27
3
  * Fix nested describes in ruby 1.8
data/Gemfile CHANGED
@@ -2,6 +2,6 @@ source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- version = ENV["RAILS_VERSION"] || "4.0"
5
+ version = ENV["RAILS_VERSION"] || "4.1"
6
6
 
7
7
  eval_gemfile File.expand_path("../gemfiles/#{version}.gemfile", __FILE__)
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Mike Moore
1
+ Copyright (c) 2014 Mike Moore
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/Manifest.txt CHANGED
@@ -7,43 +7,42 @@ LICENSE
7
7
  Manifest.txt
8
8
  README.rdoc
9
9
  Rakefile
10
- gemfiles/3.0.gemfile
11
- gemfiles/3.1.gemfile
12
- gemfiles/3.2.gemfile
13
- gemfiles/4.0.gemfile
14
- gemfiles/minitest_tu_shim.rb
10
+ gemfiles/4.1.gemfile
15
11
  lib/generators/.document
16
- lib/generators/mini_test.rb
17
- lib/generators/mini_test/controller/controller_generator.rb
18
- lib/generators/mini_test/controller/templates/controller_spec.rb
19
- lib/generators/mini_test/controller/templates/controller_test.rb
20
- lib/generators/mini_test/helper/helper_generator.rb
21
- lib/generators/mini_test/helper/templates/helper_spec.rb
22
- lib/generators/mini_test/helper/templates/helper_test.rb
23
- lib/generators/mini_test/install/install_generator.rb
24
- lib/generators/mini_test/install/templates/test_helper.rb
25
- lib/generators/mini_test/integration/integration_generator.rb
26
- lib/generators/mini_test/integration/templates/integration_spec.rb
27
- lib/generators/mini_test/integration/templates/integration_test.rb
28
- lib/generators/mini_test/mailer/mailer_generator.rb
29
- lib/generators/mini_test/mailer/templates/mailer_spec.rb
30
- lib/generators/mini_test/mailer/templates/mailer_test.rb
31
- lib/generators/mini_test/model/model_generator.rb
32
- lib/generators/mini_test/model/templates/fixtures.yml
33
- lib/generators/mini_test/model/templates/model_spec.rb
34
- lib/generators/mini_test/model/templates/model_test.rb
35
- lib/generators/mini_test/route/route_generator.rb
36
- lib/generators/mini_test/route/templates/route_spec.rb
37
- lib/generators/mini_test/route/templates/route_test.rb
38
- lib/generators/mini_test/scaffold/scaffold_generator.rb
39
- lib/generators/mini_test/scaffold/templates/controller_spec.rb
40
- lib/generators/mini_test/scaffold/templates/controller_test.rb
12
+ lib/generators/minitest.rb
13
+ lib/generators/minitest/controller/controller_generator.rb
14
+ lib/generators/minitest/controller/templates/controller_spec.rb
15
+ lib/generators/minitest/controller/templates/controller_test.rb
16
+ lib/generators/minitest/generator/generator_generator.rb
17
+ lib/generators/minitest/generator/templates/generator_spec.rb
18
+ lib/generators/minitest/generator/templates/generator_test.rb
19
+ lib/generators/minitest/helper/helper_generator.rb
20
+ lib/generators/minitest/helper/templates/helper_spec.rb
21
+ lib/generators/minitest/helper/templates/helper_test.rb
22
+ lib/generators/minitest/install/install_generator.rb
23
+ lib/generators/minitest/install/templates/test_helper.rb
24
+ lib/generators/minitest/integration/integration_generator.rb
25
+ lib/generators/minitest/integration/templates/integration_spec.rb
26
+ lib/generators/minitest/integration/templates/integration_test.rb
27
+ lib/generators/minitest/mailer/mailer_generator.rb
28
+ lib/generators/minitest/mailer/templates/mailer_spec.rb
29
+ lib/generators/minitest/mailer/templates/mailer_test.rb
30
+ lib/generators/minitest/mailer/templates/preview.rb
31
+ lib/generators/minitest/model/model_generator.rb
32
+ lib/generators/minitest/model/templates/fixtures.yml
33
+ lib/generators/minitest/model/templates/model_spec.rb
34
+ lib/generators/minitest/model/templates/model_test.rb
35
+ lib/generators/minitest/route/route_generator.rb
36
+ lib/generators/minitest/route/templates/route_spec.rb
37
+ lib/generators/minitest/route/templates/route_test.rb
38
+ lib/generators/minitest/scaffold/scaffold_generator.rb
39
+ lib/generators/minitest/scaffold/templates/controller_spec.rb
40
+ lib/generators/minitest/scaffold/templates/controller_test.rb
41
41
  lib/minitest-rails.rb
42
42
  lib/minitest/rails.rb
43
43
  lib/minitest/rails/assertions.rb
44
44
  lib/minitest/rails/constant_lookup.rb
45
45
  lib/minitest/rails/expectations.rb
46
- lib/minitest/rails/generators.rb
47
46
  lib/minitest/rails/railtie.rb
48
47
  lib/minitest/rails/tasks/.document
49
48
  lib/minitest/rails/tasks/minitest.rake
@@ -53,6 +52,7 @@ lib/minitest/rails/version.rb
53
52
  minitest-rails.gemspec
54
53
  tasks/test.rake
55
54
  test/generators/test_controller_generator.rb
55
+ test/generators/test_generator_generator.rb
56
56
  test/generators/test_helper_generator.rb
57
57
  test/generators/test_install_generator.rb
58
58
  test/generators/test_mailer_generator.rb
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = minitest-rails
2
2
 
3
- MiniTest integration for Rails 3 and 4
3
+ Minitest integration for Rails 4.1+
4
4
 
5
5
  {<img src="https://secure.travis-ci.org/blowmage/minitest-rails.png" alt="Build Status" />}[http://travis-ci.org/blowmage/minitest-rails]
6
6
  {<img src="https://codeclimate.com/github/blowmage/minitest-rails.png" />}[https://codeclimate.com/github/blowmage/minitest-rails]
@@ -23,21 +23,25 @@ Add <tt>minitest-rails</tt> to the Gemfile:
23
23
 
24
24
  gem "minitest-rails"
25
25
 
26
+ If you are running Rails 4.0 or earlier, be sure to specify a 1.x release in the Gemfile:
27
+
28
+ gem "minitest-rails", "~> 1.0"
29
+
26
30
  Next run the installation generator with the following:
27
31
 
28
- rails generate mini_test:install
32
+ rails generate minitest:install
29
33
 
30
34
  This will add the <tt>test_helper.rb</tt> file to the <tt>test</tt> directory.
31
35
 
32
36
  == Usage
33
37
 
34
- This project aims to enable MiniTest within the Rails TestCase classes.
38
+ This project aims to enable Minitest within the Rails TestCase classes.
35
39
  Your test will continue to inherit from <tt>ActiveSupport::TestCase</tt>, which will now support the spec DSL.
36
40
  You can generate test files with the standard model, controller, resource, and other generators:
37
41
 
38
42
  rails generate model User
39
43
 
40
- And you can specify generating the tests using the <tt>MiniTest::Spec</tt> DSL on any of the generators by providing the <tt>--spec</tt> option:
44
+ And you can specify generating the tests using the <tt>Minitest::Spec</tt> DSL on any of the generators by providing the <tt>--spec</tt> option:
41
45
 
42
46
  rails generate model User --spec
43
47
 
@@ -48,7 +52,7 @@ And you can specify not generating the fixture for a model by providing the <tt>
48
52
  You can also set these as defaults by adding the following to the <tt>config/application.rb</tt> file:
49
53
 
50
54
  config.generators do |g|
51
- g.test_framework :mini_test, :spec => true, :fixture => false
55
+ g.test_framework :minitest, spec: true, fixture: false
52
56
  end
53
57
 
54
58
  To run your tests, minitest-rails provides multiple rake tasks by default, for a complete list, simply run <tt>rake -T</tt>.
@@ -57,25 +61,19 @@ You can also add any directories under <tt>test/</tt> and minitest-rails will au
57
61
 
58
62
  If you want to automatically run <tt>rake minitest:api</tt> when you call <tt>rake minitest</tt>, add this line to a new .rake file under <tt>lib/tasks/</tt>:
59
63
 
60
- MiniTest::Rails::Testing.default_tasks << 'api'
64
+ Minitest::Rails::Testing.default_tasks << 'api'
61
65
 
62
- == Running on Ruby 1.8
66
+ == Using Rails 4.0 or earlier
63
67
 
64
- Efforts have been made to be compatible with Ruby 1.8.7, but some rough edges may remain. For the latest information on 1.8 compatibility see the wiki: https://github.com/blowmage/minitest-rails/wiki/Running-on-1.8
68
+ For information on running Rails 3.0 through 4.0, see the README for the 1.x branch: https://github.com/blowmage/minitest-rails/tree/1.x#readme
65
69
 
66
70
  == Capybara
67
71
 
68
72
  You can use Capybara for feature tests by adding <tt>minitest-rails-capybara</tt> as a dependency. See the README for more information: https://github.com/blowmage/minitest-rails-capybara
69
73
 
70
- == Upgrading
71
-
72
- The 0.9 release marks a new direction for minitest-rails. Deprecations have been added for the features that won't make it to 1.0. See instructions for upgrading to 0.9: https://github.com/blowmage/minitest-rails/wiki/Upgrading-to-0.9
73
-
74
- == Incompatibilities
75
-
76
- Existing tests that call <tt>describe</tt> will not work, since <tt>describe</tt> is used by <tt>MiniTest::Spec</tt> blocks.
74
+ == RSpec Compatibility
77
75
 
78
- RSpec and minitest's spec DSL are incompatible and cannot both be loaded at the same time. If your tests using the spec DSL are not running it is likely the RSpec DSL is also loaded. Check the dependencies and make sure RSpec is only loaded when running the specs.
76
+ RSpec and Minitest's spec DSL are incompatible and both cannot be loaded at the same time. If your tests using the spec DSL are not running it is likely the RSpec DSL is also loaded. Check the dependencies and make sure RSpec is only loaded when running the specs.
79
77
 
80
78
  If you need to use some RSpec features with minitest-rails require only the needed gems. e.g. To use RSpec mocks with minitest-rails require the "rspec-mocks" gem only, and not the main "rspec" gem which activates the RSpec DSL.
81
79
 
@@ -87,7 +85,7 @@ https://groups.google.com/group/minitest-rails
87
85
 
88
86
  == License
89
87
 
90
- Copyright (c) 2013 Mike Moore
88
+ Copyright (c) 2014 Mike Moore
91
89
 
92
90
  Permission is hereby granted, free of charge, to any person obtaining
93
91
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -9,8 +9,8 @@ Hoe.plugin :gemspec
9
9
  Hoe.spec "minitest-rails" do
10
10
  developer "Mike Moore", "mike@blowmage.com"
11
11
 
12
- self.summary = "MiniTest integration for Rails 3 and 4"
13
- self.description = "Adds MiniTest as the default testing library in Rails 3 and 4"
12
+ self.summary = "Minitest integration for Rails 4.1+"
13
+ self.description = "Adds Minitest as the default testing library in Rails 3 and 4"
14
14
  self.urls = ["http://blowmage.com/minitest-rails"]
15
15
 
16
16
  self.history_file = "CHANGELOG.rdoc"
@@ -19,10 +19,9 @@ Hoe.spec "minitest-rails" do
19
19
 
20
20
  license "MIT"
21
21
 
22
- dependency "minitest", "~> 4.7"
23
- dependency "minitest-test", "~> 1.0"
24
- dependency "railties", [ ">= 3.0", "< 4.1" ]
25
- dependency "fakefs", "= 0.4.3", :dev
22
+ dependency "minitest", [ ">= 5.3.3", "< 6.0" ]
23
+ dependency "railties", "~> 4.1"
24
+ dependency "fakefs", "= 0.4.3", :dev
26
25
  end
27
26
 
28
27
  Dir["tasks/**/*.rake"].each { |t| load t }
@@ -1,4 +1,5 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "rails", "~> 4.0.4"
3
+ gem "rails", "~> 4.1.0"
4
+ gem "sqlite3"
4
5
  gem "rake"
@@ -0,0 +1,20 @@
1
+ require "generators/minitest"
2
+
3
+ module Minitest
4
+ module Generators
5
+ class ControllerGenerator < Base
6
+ argument :actions, type: :array, default: [], banner: "action action"
7
+ check_class_collision suffix: "ControllerTest"
8
+
9
+ def create_test_files
10
+ if options[:spec]
11
+ template_file = "controller_spec.rb"
12
+ else
13
+ template_file = "controller_test.rb"
14
+ end
15
+ template template_file,
16
+ File.join("test/controllers", class_path, "#{file_name}_controller_test.rb")
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,32 @@
1
+ require "generators/minitest"
2
+
3
+ module Minitest
4
+ module Generators
5
+ class GeneratorGenerator < Base
6
+ check_class_collision suffix: "GeneratorTest"
7
+
8
+ class_option :namespace, type: :boolean, default: true,
9
+ desc: "Namespace generator under lib/generators/name"
10
+
11
+ def create_generator_files
12
+ if options[:spec]
13
+ template_file = "generator_spec.rb"
14
+ else
15
+ template_file = "generator_test.rb"
16
+ end
17
+ template template_file,
18
+ File.join("test/lib/generators", class_path, "#{file_name}_generator_test.rb")
19
+ end
20
+
21
+ protected
22
+
23
+ def generator_path
24
+ if options[:namespace]
25
+ File.join("generators", regular_class_path, file_name, "#{file_name}_generator")
26
+ else
27
+ File.join("generators", regular_class_path, "#{file_name}_generator")
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,14 @@
1
+ require "test_helper"
2
+ require "<%= generator_path %>"
3
+
4
+ <% module_namespacing do -%>
5
+ describe <%= class_name %>Generator do
6
+ destination Rails.root.join("tmp/generators")
7
+ setup :prepare_destination
8
+
9
+ # it "generator runs without errors" do
10
+ # # No error raised? It passes.
11
+ # run_generator ["arguments"]
12
+ # end
13
+ end
14
+ <% end -%>
@@ -0,0 +1,15 @@
1
+ require "test_helper"
2
+ require "<%= generator_path %>"
3
+
4
+ <% module_namespacing do -%>
5
+ class <%= class_name %>GeneratorTest < Rails::Generators::TestCase
6
+ tests <%= class_name %>Generator
7
+ destination Rails.root.join("tmp/generators")
8
+ setup :prepare_destination
9
+
10
+ # def test_generator_runs
11
+ # # No error raised? It passes.
12
+ # run_generator ["arguments"]
13
+ # end
14
+ end
15
+ <% end -%>
@@ -0,0 +1,19 @@
1
+ require "generators/minitest"
2
+
3
+ module Minitest
4
+ module Generators
5
+ class HelperGenerator < Base
6
+ check_class_collision suffix: "HelperTest"
7
+
8
+ def create_helper_files
9
+ if options[:spec]
10
+ template_file = "helper_spec.rb"
11
+ else
12
+ template_file = "helper_test.rb"
13
+ end
14
+ template template_file,
15
+ File.join("test/helpers", class_path, "#{file_name}_helper_test.rb")
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,6 +1,5 @@
1
1
  require "test_helper"
2
2
 
3
- <% module_namespacing do -%>
4
3
  describe <%= class_name %>Helper do
5
4
 
6
5
  it "must be a real test" do
@@ -8,4 +7,3 @@ describe <%= class_name %>Helper do
8
7
  end
9
8
 
10
9
  end
11
- <% end -%>
@@ -1,9 +1,9 @@
1
1
  require 'rails/generators'
2
2
 
3
- module MiniTest
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 :active_record, type: :boolean, default: true, desc: "Add ActiveRecord configuration"
7
7
 
8
8
  desc <<DESC
9
9
  Description:
@@ -0,0 +1,19 @@
1
+ require "generators/minitest"
2
+
3
+ module Minitest
4
+ module Generators
5
+ class IntegrationGenerator < Base
6
+ check_class_collision suffix: "Test"
7
+
8
+ def create_test_files
9
+ if options[:spec]
10
+ template_file = "integration_spec.rb"
11
+ else
12
+ template_file = "integration_test.rb"
13
+ end
14
+ template template_file,
15
+ File.join("test/integration", class_path, "#{file_name}_test.rb")
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,27 @@
1
+ require "generators/minitest"
2
+
3
+ module Minitest
4
+ module Generators
5
+ class MailerGenerator < Base
6
+ argument :actions, type: :array, default: [], banner: "method method"
7
+
8
+ def check_class_collision
9
+ class_collisions "#{class_name}Test", "#{class_name}Preview"
10
+ end
11
+
12
+ def create_test_files
13
+ if options[:spec]
14
+ template_file = "mailer_spec.rb"
15
+ else
16
+ template_file = "mailer_test.rb"
17
+ end
18
+ template template_file,
19
+ File.join("test/mailers", class_path, "#{file_name}_test.rb")
20
+ end
21
+
22
+ def create_preview_files
23
+ template "preview.rb", File.join("test/mailers/previews", class_path, "#{file_name}_preview.rb")
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,13 @@
1
+ <% module_namespacing do -%>
2
+ # Preview all emails at http://localhost:3000/rails/mailers/<%= file_path %>
3
+ class <%= class_name %>Preview < ActionMailer::Preview
4
+ <% actions.each do |action| -%>
5
+
6
+ # Preview this email at http://localhost:3000/rails/mailers/<%= file_path %>/<%= action %>
7
+ def <%= action %>
8
+ <%= class_name %>.<%= action %>
9
+ end
10
+ <% end -%>
11
+
12
+ end
13
+ <% end -%>
@@ -0,0 +1,42 @@
1
+ require "generators/minitest"
2
+
3
+ module Minitest
4
+ module Generators
5
+ class ModelGenerator < Base
6
+ RESERVED_YAML_KEYWORDS = %w(y yes n no true false on off null)
7
+
8
+ argument :attributes, type: :array, default: [], banner: "field:type field:type"
9
+ class_option :fixture, type: :boolean, default: true, desc: "Create fixture file"
10
+
11
+ check_class_collision suffix: "Test"
12
+
13
+ def create_test_file
14
+ if options[:spec]
15
+ template_file = "model_spec.rb"
16
+ else
17
+ template_file = "model_test.rb"
18
+ end
19
+ template template_file,
20
+ File.join("test/models", class_path, "#{file_name}_test.rb")
21
+ end
22
+
23
+ hook_for :fixture_replacement
24
+
25
+ def create_fixture_file
26
+ if options[:fixture] && options[:fixture_replacement].nil?
27
+ template "fixtures.yml", File.join("test/fixtures", class_path, "#{plural_file_name}.yml")
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def yaml_key_value(key, value)
34
+ if RESERVED_YAML_KEYWORDS.include?(key.downcase)
35
+ "'#{key}': #{value}"
36
+ else
37
+ "#{key}: #{value}"
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,11 +1,11 @@
1
- require "generators/mini_test"
1
+ require "generators/minitest"
2
2
 
3
- module MiniTest
3
+ module Minitest
4
4
  module Generators
5
5
  class RouteGenerator < ::Rails::Generators::Base
6
6
 
7
- class_option :spec, :type => :boolean, :default => false,
8
- :desc => "Use MiniTest::Spec DSL"
7
+ class_option :spec, type: :boolean, default: false,
8
+ desc: "Use Minitest::Spec DSL"
9
9
 
10
10
  desc <<DESC
11
11
  Description:
@@ -1,7 +1,7 @@
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
+ # Minitest::Rails::Testing.default_tasks << "routes"
5
5
 
6
6
  describe "Route Integration Test" do
7
7
  it "route root" do
@@ -1,7 +1,7 @@
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
+ # Minitest::Rails::Testing.default_tasks << "routes"
5
5
 
6
6
  class RouteTest < ActionDispatch::IntegrationTest
7
7
  def test_root
@@ -0,0 +1,38 @@
1
+ require "generators/minitest"
2
+ require "rails/generators/resource_helpers"
3
+
4
+ module Minitest
5
+ module Generators
6
+ class ScaffoldGenerator < Base
7
+ include ::Rails::Generators::ResourceHelpers
8
+
9
+ check_class_collision suffix: "ControllerTest"
10
+
11
+ argument :attributes, type: :array, default: [], banner: "field:type field:type"
12
+
13
+ def create_test_files
14
+ if options[:spec]
15
+ template_file = "controller_spec.rb"
16
+ else
17
+ template_file = "controller_test.rb"
18
+ end
19
+ template template_file,
20
+ File.join("test/controllers", controller_class_path, "#{controller_file_name}_controller_test.rb")
21
+ end
22
+
23
+ private
24
+
25
+ def attributes_hash
26
+ return if attributes_names.empty?
27
+
28
+ attributes_names.map do |name|
29
+ if %w(password password_confirmation).include?(name) && attributes.any?(&:password_digest?)
30
+ "#{name}: 'secret'"
31
+ else
32
+ "#{name}: @#{singular_table_name}.#{name}"
33
+ end
34
+ end.sort.join(", ")
35
+ end
36
+ end
37
+ end
38
+ end