minitest-rails 0.0.7 → 0.1

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.
Files changed (56) hide show
  1. data/CHANGELOG.rdoc +22 -0
  2. data/LICENSE +20 -0
  3. data/Manifest.txt +30 -25
  4. data/README.rdoc +46 -15
  5. data/Rakefile +4 -4
  6. data/lib/generators/{minitest → mini_test}/controller/controller_generator.rb +5 -5
  7. data/lib/generators/{minitest/controller/templates/controller_test.rb → mini_test/controller/templates/controller_spec.rb} +6 -7
  8. data/lib/generators/mini_test/controller/templates/controller_test.rb +19 -0
  9. data/lib/generators/mini_test/helper/helper_generator.rb +19 -0
  10. data/lib/generators/{minitest → mini_test}/helper/templates/helper_test.rb +1 -1
  11. data/lib/generators/{minitest → mini_test}/install/install_generator.rb +1 -1
  12. data/lib/generators/mini_test/install/templates/test/minitest_helper.rb +25 -0
  13. data/lib/generators/mini_test/integration/integration_generator.rb +19 -0
  14. data/lib/generators/mini_test/integration/templates/integration_spec.rb +8 -0
  15. data/lib/generators/mini_test/integration/templates/integration_test.rb +7 -0
  16. data/lib/generators/{minitest → mini_test}/mailer/mailer_generator.rb +3 -3
  17. data/lib/generators/{minitest → mini_test}/mailer/templates/mailer_spec.rb +2 -2
  18. data/lib/generators/{minitest → mini_test}/mailer/templates/mailer_test.rb +5 -5
  19. data/lib/generators/{minitest → mini_test}/model/model_generator.rb +5 -5
  20. data/lib/generators/mini_test/model/templates/model_spec.rb +13 -0
  21. data/lib/generators/mini_test/model/templates/model_test.rb +9 -0
  22. data/lib/generators/mini_test/scaffold/scaffold_generator.rb +28 -0
  23. data/lib/generators/{minitest → mini_test}/scaffold/templates/controller_spec.rb +2 -6
  24. data/lib/generators/{minitest → mini_test}/scaffold/templates/controller_test.rb +3 -2
  25. data/lib/generators/{minitest.rb → mini_test.rb} +2 -2
  26. data/lib/minitest/rails/action_controller.rb +19 -0
  27. data/lib/minitest/rails/action_dispatch.rb +36 -0
  28. data/lib/minitest/rails/action_mailer.rb +17 -0
  29. data/lib/minitest/rails/action_view.rb +18 -0
  30. data/lib/minitest/rails/active_support.rb +68 -0
  31. data/lib/minitest/rails/tasks/minitest.rake +32 -15
  32. data/lib/minitest/rails.rb +54 -5
  33. data/lib/minitest-rails.rb +11 -5
  34. data/minitest-rails.gemspec +42 -0
  35. data/test/test_controller_generator.rb +30 -10
  36. data/test/test_helper_generator.rb +30 -5
  37. data/test/test_install_generator.rb +5 -13
  38. data/test/test_mailer_generator.rb +5 -6
  39. data/test/test_minitest.rb +2 -2
  40. data/test/test_model_generator.rb +27 -7
  41. data/test/test_scaffold_generator.rb +5 -8
  42. metadata +65 -41
  43. data/lib/generators/minitest/controller/templates/controller_spec.rb +0 -17
  44. data/lib/generators/minitest/helper/helper_generator.rb +0 -19
  45. data/lib/generators/minitest/install/templates/test/minitest_helper.rb +0 -61
  46. data/lib/generators/minitest/model/templates/model_spec.rb +0 -28
  47. data/lib/generators/minitest/model/templates/model_test.rb +0 -11
  48. data/lib/generators/minitest/scaffold/scaffold_generator.rb +0 -22
  49. data/lib/minitest/rails/controller.rb +0 -104
  50. data/lib/minitest/rails/fixtures.rb +0 -14
  51. data/lib/minitest/rails/helper.rb +0 -30
  52. data/lib/minitest/rails/mailer.rb +0 -8
  53. data/lib/minitest/rails/model.rb +0 -8
  54. data/lib/minitest/rails/spec.rb +0 -14
  55. /data/lib/generators/{minitest → mini_test}/helper/templates/helper_spec.rb +0 -0
  56. /data/lib/generators/{minitest → mini_test}/model/templates/fixtures.yml +0 -0
data/CHANGELOG.rdoc CHANGED
@@ -1,7 +1,29 @@
1
+ === 0.1.0 / 2012-07-09
2
+
3
+ This is a major change. The approach used is the same approach used in Rails 4. This version is very different than the 0.0.x versions.
4
+
5
+ https://github.com/blowmage/minitest-rails/compare/v0.0.7...v0.1
6
+
7
+ === 0.0.7 / 2012-05-19
8
+
9
+ * Use the Minitest constant
10
+
11
+ https://github.com/blowmage/minitest-rails/compare/v0.0.6...v0.0.7
12
+
13
+ === 0.0.6 / 2012-03-14
14
+
15
+ https://github.com/blowmage/minitest-rails/compare/v0.0.5...v0.0.6
16
+
17
+ === 0.0.5 / 2011-06-22
18
+
19
+ https://github.com/blowmage/minitest-rails/compare/v0.0.4...v0.0.5
20
+
1
21
  === 0.0.4 / 2011-06-08
2
22
 
3
23
  Add scaffold, bump to Rails 3.1.0.rc2
4
24
 
25
+ https://github.com/blowmage/minitest-rails/compare/v0.0.2...v0.0.4
26
+
5
27
  === 0.0.2 / 2011-06-02
6
28
 
7
29
  Incomplete, but no longer in (known) a broken state.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Mike Moore
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt CHANGED
@@ -1,36 +1,41 @@
1
1
  .autotest
2
+ .gemtest
2
3
  CHANGELOG.rdoc
4
+ LICENSE
3
5
  Manifest.txt
4
6
  README.rdoc
5
7
  Rakefile
6
- lib/generators/minitest.rb
7
- lib/generators/minitest/controller/controller_generator.rb
8
- lib/generators/minitest/controller/templates/controller_spec.rb
9
- lib/generators/minitest/controller/templates/controller_test.rb
10
- lib/generators/minitest/helper/helper_generator.rb
11
- lib/generators/minitest/helper/templates/helper_spec.rb
12
- lib/generators/minitest/helper/templates/helper_test.rb
13
- lib/generators/minitest/install/install_generator.rb
14
- lib/generators/minitest/install/templates/test/minitest_helper.rb
15
- lib/generators/minitest/mailer/mailer_generator.rb
16
- lib/generators/minitest/mailer/templates/mailer_spec.rb
17
- lib/generators/minitest/mailer/templates/mailer_test.rb
18
- lib/generators/minitest/model/model_generator.rb
19
- lib/generators/minitest/model/templates/fixtures.yml
20
- lib/generators/minitest/model/templates/model_spec.rb
21
- lib/generators/minitest/model/templates/model_test.rb
22
- lib/generators/minitest/scaffold/scaffold_generator.rb
23
- lib/generators/minitest/scaffold/templates/controller_spec.rb
24
- lib/generators/minitest/scaffold/templates/controller_test.rb
8
+ lib/generators/mini_test.rb
9
+ lib/generators/mini_test/controller/controller_generator.rb
10
+ lib/generators/mini_test/controller/templates/controller_spec.rb
11
+ lib/generators/mini_test/controller/templates/controller_test.rb
12
+ lib/generators/mini_test/helper/helper_generator.rb
13
+ lib/generators/mini_test/helper/templates/helper_spec.rb
14
+ lib/generators/mini_test/helper/templates/helper_test.rb
15
+ lib/generators/mini_test/install/install_generator.rb
16
+ lib/generators/mini_test/install/templates/test/minitest_helper.rb
17
+ lib/generators/mini_test/integration/integration_generator.rb
18
+ lib/generators/mini_test/integration/templates/integration_spec.rb
19
+ lib/generators/mini_test/integration/templates/integration_test.rb
20
+ lib/generators/mini_test/mailer/mailer_generator.rb
21
+ lib/generators/mini_test/mailer/templates/mailer_spec.rb
22
+ lib/generators/mini_test/mailer/templates/mailer_test.rb
23
+ lib/generators/mini_test/model/model_generator.rb
24
+ lib/generators/mini_test/model/templates/fixtures.yml
25
+ lib/generators/mini_test/model/templates/model_spec.rb
26
+ lib/generators/mini_test/model/templates/model_test.rb
27
+ lib/generators/mini_test/scaffold/scaffold_generator.rb
28
+ lib/generators/mini_test/scaffold/templates/controller_spec.rb
29
+ lib/generators/mini_test/scaffold/templates/controller_test.rb
25
30
  lib/minitest-rails.rb
26
31
  lib/minitest/rails.rb
27
- lib/minitest/rails/controller.rb
28
- lib/minitest/rails/fixtures.rb
29
- lib/minitest/rails/helper.rb
30
- lib/minitest/rails/mailer.rb
31
- lib/minitest/rails/model.rb
32
- lib/minitest/rails/spec.rb
32
+ lib/minitest/rails/action_controller.rb
33
+ lib/minitest/rails/action_dispatch.rb
34
+ lib/minitest/rails/action_mailer.rb
35
+ lib/minitest/rails/action_view.rb
36
+ lib/minitest/rails/active_support.rb
33
37
  lib/minitest/rails/tasks/minitest.rake
38
+ minitest-rails.gemspec
34
39
  test/test_controller_generator.rb
35
40
  test/test_helper_generator.rb
36
41
  test/test_install_generator.rb
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = minitest-rails
2
2
 
3
- Minitest integration for Rails 3.1.
3
+ MiniTest integration for Rails 3.
4
4
 
5
5
  == Install
6
6
 
@@ -22,36 +22,67 @@ Add <tt>minitest-rails</tt> to the <tt>:test</tt> and <tt>:development</tt> grou
22
22
  gem 'minitest-rails'
23
23
  end
24
24
 
25
- Or, for the truly enlightened, add <tt>minitest-rails</tt> to the <tt>:test</tt> and <tt>:development</tt> groups in Isolate:
26
-
27
- env :development, :test do
28
- gem 'minitest-rails'
29
- end
30
-
31
25
  Next run the installation generator with the following:
32
26
 
33
- rails generate minitest:install
27
+ rails generate mini_test:install
34
28
 
35
29
  This will add the <tt>minitest_helper.rb</tt> file to the <tt>test</tt> directory.
36
30
 
37
31
  == Usage
38
32
 
39
- We aim to expose Minitest with minimal changes for testing within Rails.
40
- Your test classes will inherit from Minitest::Rails::Spec (or Model, or Controller, etc) and you can use the Minitest::Spec DSL.
41
- You can generate test files with the standard model, controller, scaffold, and other generators:
33
+ We aim to expose MiniTest with minimal changes for testing within Rails.
34
+ Because of this, we allow Test::Unit and MiniTest tests to live side by side.
35
+ Your test classes will inherit from MiniTest::Rails::ActiveSupport::TestCase a opposed to ActiveSupport::TestCase.
36
+ You can use the MiniTest::Spec DSL.
37
+ You can generate test files with the standard model, controller, resource, and other generators:
42
38
 
43
39
  rails generate model User
44
40
 
45
- And you can specify generating the tests using the Minitest::Spec DSL on any of the generators by providing the <tt>--spec</tt> option:
41
+ And you can specify generating the tests using the MiniTest::Spec DSL on any of the generators by providing the <tt>--spec</tt> option:
46
42
 
47
43
  rails generate model User --spec
48
44
 
49
- And you can specify generating the fixture for a model by providing the <tt>--fixture</tt> option:
45
+ And you can specify not generating the fixture for a model by providing the <tt>--skip-fixture</tt> option:
50
46
 
51
- rails generate model User --fixture
47
+ rails generate model User --skip-fixture
52
48
 
53
49
  You can also set these as defaults by adding the following to the <tt>config/application.rb</tt> file:
54
50
 
55
51
  config.generators do |g|
56
- g.test_framework :minitest, :spec => true, :fixture => true
52
+ g.test_framework :mini_test, :spec => true, :fixture => false
53
+ end
54
+
55
+ == Overriding Test::Unit
56
+
57
+ Of course, you may not want to maintain separate Test::Unit and MiniTest tests.
58
+ If this is the behavior you are wanting, simply add the following to your <tt>test_helper.rb</tt> file:
59
+
60
+ require "minitest/rails"
61
+ MiniTest::Rails.override_testunit!
62
+
63
+ == Capybara
64
+
65
+ You can use Capybara in your acceptance/integration tests by adding <tt>minitest-rails-capybara</tt> as a dependency.
66
+
67
+ group :test, :development do
68
+ gem 'minitest-rails'
69
+ gem 'minitest-rails-capybara'
57
70
  end
71
+
72
+ And add the following to your test helper file:
73
+
74
+ require "minitest/rails/capybara"
75
+
76
+ See the <tt>minitest-rails-capybara</tt> project for more information.
77
+
78
+ == Get Involved
79
+
80
+ Join the mailing list to get help or offer suggestions.
81
+
82
+ https://groups.google.com/group/minitest-rails
83
+
84
+ == License
85
+
86
+ Copyright © 2012 Mike Moore.
87
+
88
+ Released under the MIT license. See `LICENSE` for details.
data/Rakefile CHANGED
@@ -10,16 +10,16 @@ Hoe.plugins.delete :rubyforge
10
10
  Hoe.spec 'minitest-rails' do
11
11
  developer 'Mike Moore', 'mike@blowmage.com'
12
12
 
13
- self.summary = 'Minitest integration for Rails 3.'
14
- self.description = 'Adds Minitest as the default testing library in Rails 3.'
13
+ self.summary = 'MiniTest integration for Rails 3.'
14
+ self.description = 'Adds MiniTest as the default testing library in Rails 3.'
15
15
  self.urls = ['http://blowmage.com/minitest-rails']
16
16
 
17
17
  self.history_file = "CHANGELOG.rdoc"
18
18
  self.readme_file = "README.rdoc"
19
19
  self.testlib = :minitest
20
20
 
21
- extra_deps << ['minitest', '~> 2.12']
22
- extra_deps << ['rails', '~> 3.1']
21
+ extra_deps << ['minitest', '~> 3.0']
22
+ extra_deps << ['rails', '~> 3.0']
23
23
  end
24
24
 
25
25
  # vim: syntax=ruby
@@ -1,18 +1,18 @@
1
- require "generators/minitest"
1
+ require "generators/mini_test"
2
2
 
3
- module Minitest
3
+ module MiniTest
4
4
  module Generators
5
5
  class ControllerGenerator < Base
6
6
  argument :actions, :type => :array, :default => [], :banner => "action action"
7
- class_option :spec, :type => :boolean, :default => false, :desc => "Use Minitest::Spec DSL"
7
+ class_option :spec, :type => :boolean, :default => false, :desc => "Use MiniTest::Spec DSL"
8
8
 
9
9
  check_class_collision :suffix => "ControllerTest"
10
10
 
11
11
  def create_test_files
12
12
  if options[:spec]
13
- template "controller_spec.rb", "test/controllers/#{file_name}_controller_test.rb"
13
+ template "controller_spec.rb", File.join("test/controllers", class_path, "#{file_name}_controller_test.rb")
14
14
  else
15
- template "controller_test.rb", "test/controllers/#{file_name}_controller_test.rb"
15
+ template "controller_test.rb", File.join("test/controllers", class_path, "#{file_name}_controller_test.rb")
16
16
  end
17
17
  end
18
18
  end
@@ -1,15 +1,14 @@
1
1
  require "minitest_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
- class <%= class_name %>ControllerTest < Minitest::Rails::Controller
5
-
4
+ describe <%= class_name %>Controller do
6
5
  <% if actions.empty? -%>
7
- def test_sanity
8
- flunk "Need real tests"
9
- end
6
+ # it "must be a real test" do
7
+ # flunk "Need real tests"
8
+ # end
10
9
  <% else -%>
11
10
  <% actions.each do |action| -%>
12
- def test_<%= action %>
11
+ it "should get <%= action %>" do
13
12
  get :<%= action %>
14
13
  assert_response :success
15
14
  end
@@ -17,4 +16,4 @@ class <%= class_name %>ControllerTest < Minitest::Rails::Controller
17
16
  <% end -%>
18
17
  <% end -%>
19
18
  end
20
- <% end -%>
19
+ <% end -%>
@@ -0,0 +1,19 @@
1
+ require "minitest_helper"
2
+
3
+ <% module_namespacing do -%>
4
+ class <%= class_name %>ControllerTest < MiniTest::Rails::ActionController::TestCase
5
+ <% if actions.empty? -%>
6
+ # test "the truth" do
7
+ # assert true
8
+ # end
9
+ <% else -%>
10
+ <% actions.each do |action| -%>
11
+ test "should get <%= action %>" do
12
+ get :<%= action %>
13
+ assert_response :success
14
+ end
15
+
16
+ <% end -%>
17
+ <% end -%>
18
+ end
19
+ <% end -%>
@@ -0,0 +1,19 @@
1
+ require "generators/mini_test"
2
+
3
+ module MiniTest
4
+ module Generators
5
+ class HelperGenerator < Base
6
+ class_option :spec, :type => :boolean, :default => false, :desc => "Use MiniTest::Spec DSL"
7
+
8
+ check_class_collision :suffix => "HelperTest"
9
+
10
+ def create_test_files
11
+ if options[:spec]
12
+ template "helper_spec.rb", File.join("test/helpers", class_path, "#{file_name}_helper_test.rb")
13
+ else
14
+ template "helper_test.rb", File.join("test/helpers", class_path, "#{file_name}_helper_test.rb")
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,7 +1,7 @@
1
1
  require "minitest_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
- class <%= class_name %>HelperTest < Minitest::Rails::Helper
4
+ class <%= class_name %>HelperTest < MiniTest::Rails::ActionView::TestCase
5
5
 
6
6
  def test_sanity
7
7
  flunk "Need real tests"
@@ -1,6 +1,6 @@
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
6
 
@@ -0,0 +1,25 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+ require File.expand_path('../../config/environment', __FILE__)
3
+
4
+ require "minitest/autorun"
5
+ require "minitest/rails"
6
+
7
+ # Uncomment if you want Capybara in accceptance/integration tests
8
+ # require "minitest/rails/capybara"
9
+
10
+ # Uncomment if you want awesome colorful output
11
+ # require "minitest/pride"
12
+
13
+ class MiniTest::Rails::ActiveSupport::TestCase
14
+ # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
15
+ fixtures :all
16
+
17
+ # Add more helper methods to be used by all tests here...
18
+ end
19
+
20
+ # Do you want all existing Rails tests to use MiniTest::Rails?
21
+ # Comment out the following and either:
22
+ # A) Change the require on the existing tests to `require "minitest_helper"`
23
+ # B) Require this file's code in test_helper.rb
24
+
25
+ # MiniTest::Rails.override_testunit!
@@ -0,0 +1,19 @@
1
+ require "generators/mini_test"
2
+
3
+ module MiniTest
4
+ module Generators
5
+ class IntegrationGenerator < Base
6
+ class_option :spec, :type => :boolean, :default => false, :desc => "Use MiniTest::Spec DSL"
7
+
8
+ check_class_collision :suffix => "Test"
9
+
10
+ def create_test_files
11
+ if options[:spec]
12
+ template 'integration_spec.rb', File.join('test/acceptance', class_path, "#{file_name}_test.rb")
13
+ else
14
+ template 'integration_test.rb', File.join('test/acceptance', class_path, "#{file_name}_test.rb")
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,8 @@
1
+ require "minitest_helper"
2
+
3
+ # To be handled correctly this spec must end with "Acceptance Test"
4
+ describe "<%= class_name %> Acceptance Test" do
5
+ # it "must be a real test" do
6
+ # flunk "Need real tests"
7
+ # end
8
+ end
@@ -0,0 +1,7 @@
1
+ require "minitest_helper"
2
+
3
+ class <%= class_name %>Test < MiniTest::Rails::ActionDispatch::IntegrationTest
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
@@ -1,10 +1,10 @@
1
- require "generators/minitest"
1
+ require "generators/mini_test"
2
2
 
3
- module Minitest
3
+ module MiniTest
4
4
  module Generators
5
5
  class MailerGenerator < Base
6
6
  argument :actions, :type => :array, :default => [], :banner => "method method"
7
- class_option :spec, :type => :boolean, :default => false, :desc => "Use Minitest::Spec DSL"
7
+ class_option :spec, :type => :boolean, :default => false, :desc => "Use MiniTest::Spec DSL"
8
8
 
9
9
  check_class_collision :suffix => "MailerTest"
10
10
 
@@ -1,7 +1,7 @@
1
1
  require "minitest_helper"
2
2
 
3
+ <% module_namespacing do -%>
3
4
  describe <%= class_name %> do
4
-
5
5
  <% actions.each do |action| -%>
6
6
  it "<%= action %>" do
7
7
  mail = <%= class_name %>.<%= action %>
@@ -16,5 +16,5 @@ describe <%= class_name %> do
16
16
  flunk "Need real tests"
17
17
  end
18
18
  <% end -%>
19
-
20
19
  end
20
+ <% end -%>
@@ -1,9 +1,9 @@
1
1
  require "minitest_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
- class <%= class_name %>Test < Minitest::Rails::Mailer
4
+ class <%= class_name %>Test < MiniTest::Rails::ActionMailer::TestCase
5
5
  <% actions.each do |action| -%>
6
- def test_<%= action %>
6
+ test "<%= action %>" do
7
7
  mail = <%= class_name %>.<%= action %>
8
8
  assert_equal <%= action.to_s.humanize.inspect %>, mail.subject
9
9
  assert_equal ["to@example.org"], mail.to
@@ -13,9 +13,9 @@ class <%= class_name %>Test < Minitest::Rails::Mailer
13
13
 
14
14
  <% end -%>
15
15
  <% if actions.blank? -%>
16
- def test_sanity
17
- flunk "Need real tests"
18
- end
16
+ # test "the truth" do
17
+ # assert true
18
+ # end
19
19
  <% end -%>
20
20
  end
21
21
  <% end -%>
@@ -1,11 +1,11 @@
1
- require "generators/minitest"
1
+ require "generators/mini_test"
2
2
 
3
- module Minitest
3
+ module MiniTest
4
4
  module Generators
5
5
  class ModelGenerator < Base
6
- argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
7
- class_option :fixture, :type => :boolean, :default => false, :desc => "Create fixture file"
8
- class_option :spec, :type => :boolean, :default => false, :desc => "Use Minitest::Spec DSL"
6
+ argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
7
+ class_option :fixture, :type => :boolean, :default => true, :desc => "Create fixture file"
8
+ class_option :spec, :type => :boolean, :default => false, :desc => "Use MiniTest::Spec DSL"
9
9
 
10
10
  check_class_collision :suffix => "Test"
11
11
 
@@ -0,0 +1,13 @@
1
+ require "minitest_helper"
2
+
3
+ <% module_namespacing do -%>
4
+ describe <%= class_name %> do
5
+ before do
6
+ @<%= file_name %> = <%= class_name %>.new
7
+ end
8
+
9
+ it "must be valid" do
10
+ @<%= file_name %>.valid?.must_equal true
11
+ end
12
+ end
13
+ <% end -%>
@@ -0,0 +1,9 @@
1
+ require "minitest_helper"
2
+
3
+ <% module_namespacing do -%>
4
+ class <%= class_name %>Test < MiniTest::Rails::ActiveSupport::TestCase
5
+ # test "the truth" do
6
+ # assert true
7
+ # end
8
+ end
9
+ <% end -%>
@@ -0,0 +1,28 @@
1
+ require "generators/mini_test"
2
+ require "rails/generators/resource_helpers"
3
+
4
+ module MiniTest
5
+ module Generators
6
+ class ScaffoldGenerator < Base
7
+ include ::Rails::Generators::ResourceHelpers
8
+ argument :actions, :type => :array, :default => [], :banner => "action action"
9
+ class_option :spec, :type => :boolean, :default => false, :desc => "Use MiniTest::Spec DSL"
10
+
11
+ check_class_collision :suffix => "ControllerTest"
12
+
13
+ def create_test_files
14
+ if options[:spec]
15
+ template "controller_spec.rb",
16
+ File.join("test/controllers",
17
+ class_path,
18
+ "#{controller_file_name}_controller_test.rb")
19
+ else
20
+ template "controller_test.rb",
21
+ File.join("test/controllers",
22
+ class_path,
23
+ "#{controller_file_name}_controller_test.rb")
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,14 +1,10 @@
1
1
  require "minitest_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
- describe <%= class_name %>Controller do
5
-
6
- subject { <%= class_name %>Controller }
7
-
8
- # fixtures :all
4
+ describe <%= controller_class_name %>Controller do
9
5
 
10
6
  before do
11
- @<%= singular_table_name %> = <%= table_name %>(:one)
7
+ @<%= singular_table_name %> = <%= class_name %>.new
12
8
  end
13
9
 
14
10
  it "must get index" do
@@ -1,9 +1,10 @@
1
1
  require "minitest_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
- class <%= class_name %>ControllerTest < Minitest::Rails::Controller
4
+ class <%= controller_class_name %>ControllerTest < MiniTest::Rails::ActionController::TestCase
5
+
5
6
  before do
6
- @<%= singular_table_name %> = <%= table_name %>(:one)
7
+ @<%= singular_table_name %> = <%= class_name %>.new
7
8
  end
8
9
 
9
10
  def test_index
@@ -1,10 +1,10 @@
1
1
  require 'rails/generators/named_base'
2
2
 
3
- module Minitest
3
+ module MiniTest
4
4
  module Generators
5
5
  class Base < ::Rails::Generators::NamedBase #:nodoc:
6
6
  def self.source_root
7
- @_minitest_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'minitest', generator_name, 'templates'))
7
+ @_minitest_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'mini_test', generator_name, 'templates'))
8
8
  end
9
9
  end
10
10
  end
@@ -0,0 +1,19 @@
1
+ require "minitest/rails/active_support"
2
+ require "action_controller/test_case"
3
+
4
+ module MiniTest
5
+ module Rails
6
+ module ActionController
7
+ class TestCase < MiniTest::Rails::ActiveSupport::TestCase
8
+ RaiseActionExceptions = ::ActionController::TestCase::RaiseActionExceptions
9
+
10
+ # Use AC::TestCase for the base class when describing a controller
11
+ register_spec_type(self) do |desc|
12
+ desc < ::ActionController::Base
13
+ end
14
+
15
+ include ::ActionController::TestCase::Behavior
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,36 @@
1
+ require 'minitest/rails/active_support'
2
+ require 'action_dispatch/testing/integration'
3
+
4
+ module MiniTest
5
+ module Rails
6
+ module ActionDispatch
7
+ class IntegrationTest < MiniTest::Rails::ActiveSupport::TestCase
8
+ include ::ActionDispatch::Integration::Runner
9
+ include ::ActionController::TemplateAssertions
10
+ include ::ActionDispatch::Routing::UrlFor
11
+
12
+ @@app = nil
13
+
14
+ def self.app
15
+ # DEPRECATE Rails application fallback
16
+ # This should be set by the initializer
17
+ @@app || (defined?(Rails.application) && Rails.application) || nil
18
+ end
19
+
20
+ def self.app=(app)
21
+ @@app = app
22
+ end
23
+
24
+ def app
25
+ super || ::ActionDispatch::IntegrationTest.app
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ # Register by name
33
+ MiniTest::Spec.register_spec_type(/AcceptanceTest$/, MiniTest::Rails::ActionDispatch::IntegrationTest)
34
+ MiniTest::Spec.register_spec_type(/Acceptance Test$/, MiniTest::Rails::ActionDispatch::IntegrationTest)
35
+ MiniTest::Spec.register_spec_type(/IntegrationTest$/, MiniTest::Rails::ActionDispatch::IntegrationTest)
36
+ MiniTest::Spec.register_spec_type(/Integration Test$/, MiniTest::Rails::ActionDispatch::IntegrationTest)