minitest-rails 0.0.7 → 0.1.0.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/Manifest.txt +27 -25
  2. data/README.rdoc +6 -6
  3. data/Rakefile +3 -3
  4. data/lib/generators/{minitest.rb → mini_test.rb} +2 -2
  5. data/lib/generators/{minitest → mini_test}/controller/controller_generator.rb +3 -3
  6. data/lib/generators/{minitest/controller/templates/controller_test.rb → mini_test/controller/templates/controller_spec.rb} +6 -7
  7. data/lib/generators/mini_test/controller/templates/controller_test.rb +19 -0
  8. data/lib/generators/{minitest → mini_test}/helper/helper_generator.rb +3 -3
  9. data/lib/generators/{minitest → mini_test}/helper/templates/helper_spec.rb +0 -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 +15 -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 +3 -3
  20. data/lib/generators/{minitest → mini_test}/model/templates/fixtures.yml +0 -0
  21. data/lib/generators/mini_test/model/templates/model_spec.rb +13 -0
  22. data/lib/generators/mini_test/model/templates/model_test.rb +9 -0
  23. data/lib/generators/{minitest → mini_test}/scaffold/scaffold_generator.rb +3 -3
  24. data/lib/generators/{minitest → mini_test}/scaffold/templates/controller_spec.rb +1 -5
  25. data/lib/generators/{minitest → mini_test}/scaffold/templates/controller_test.rb +3 -2
  26. data/lib/minitest-rails.rb +5 -5
  27. data/lib/minitest/rails.rb +40 -5
  28. data/lib/minitest/rails/action_controller.rb +17 -0
  29. data/lib/minitest/rails/action_dispatch.rb +21 -0
  30. data/lib/minitest/rails/action_mailer.rb +17 -0
  31. data/lib/minitest/rails/active_support.rb +62 -0
  32. data/lib/minitest/rails/tasks/minitest.rake +1 -1
  33. data/minitest-rails.gemspec +42 -0
  34. data/test/test_controller_generator.rb +5 -10
  35. data/test/test_helper_generator.rb +5 -5
  36. data/test/test_install_generator.rb +5 -13
  37. data/test/test_mailer_generator.rb +5 -6
  38. data/test/test_minitest.rb +2 -2
  39. data/test/test_model_generator.rb +5 -7
  40. data/test/test_scaffold_generator.rb +5 -8
  41. metadata +43 -41
  42. data/lib/generators/minitest/controller/templates/controller_spec.rb +0 -17
  43. data/lib/generators/minitest/install/templates/test/minitest_helper.rb +0 -61
  44. data/lib/generators/minitest/model/templates/model_spec.rb +0 -28
  45. data/lib/generators/minitest/model/templates/model_test.rb +0 -11
  46. data/lib/minitest/rails/controller.rb +0 -104
  47. data/lib/minitest/rails/fixtures.rb +0 -14
  48. data/lib/minitest/rails/helper.rb +0 -30
  49. data/lib/minitest/rails/mailer.rb +0 -8
  50. data/lib/minitest/rails/model.rb +0 -8
  51. data/lib/minitest/rails/spec.rb +0 -14
data/Manifest.txt CHANGED
@@ -3,34 +3,36 @@ CHANGELOG.rdoc
3
3
  Manifest.txt
4
4
  README.rdoc
5
5
  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
6
+ lib/generators/mini_test.rb
7
+ lib/generators/mini_test/controller/controller_generator.rb
8
+ lib/generators/mini_test/controller/templates/controller_spec.rb
9
+ lib/generators/mini_test/controller/templates/controller_test.rb
10
+ lib/generators/mini_test/helper/helper_generator.rb
11
+ lib/generators/mini_test/helper/templates/helper_spec.rb
12
+ lib/generators/mini_test/helper/templates/helper_test.rb
13
+ lib/generators/mini_test/install/install_generator.rb
14
+ lib/generators/mini_test/install/templates/test/minitest_helper.rb
15
+ lib/generators/mini_test/integration/integration_generator.rb
16
+ lib/generators/mini_test/integration/templates/integration_spec.rb
17
+ lib/generators/mini_test/integration/templates/integration_test.rb
18
+ lib/generators/mini_test/mailer/mailer_generator.rb
19
+ lib/generators/mini_test/mailer/templates/mailer_spec.rb
20
+ lib/generators/mini_test/mailer/templates/mailer_test.rb
21
+ lib/generators/mini_test/model/model_generator.rb
22
+ lib/generators/mini_test/model/templates/fixtures.yml
23
+ lib/generators/mini_test/model/templates/model_spec.rb
24
+ lib/generators/mini_test/model/templates/model_test.rb
25
+ lib/generators/mini_test/scaffold/scaffold_generator.rb
26
+ lib/generators/mini_test/scaffold/templates/controller_spec.rb
27
+ lib/generators/mini_test/scaffold/templates/controller_test.rb
25
28
  lib/minitest-rails.rb
26
29
  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
30
+ lib/minitest/rails/action_controller.rb
31
+ lib/minitest/rails/action_dispatch.rb
32
+ lib/minitest/rails/action_mailer.rb
33
+ lib/minitest/rails/active_support.rb
33
34
  lib/minitest/rails/tasks/minitest.rake
35
+ minitest-rails.gemspec
34
36
  test/test_controller_generator.rb
35
37
  test/test_helper_generator.rb
36
38
  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.1.
4
4
 
5
5
  == Install
6
6
 
@@ -30,19 +30,19 @@ Or, for the truly enlightened, add <tt>minitest-rails</tt> to the <tt>:test</tt>
30
30
 
31
31
  Next run the installation generator with the following:
32
32
 
33
- rails generate minitest:install
33
+ rails generate mini_test:install
34
34
 
35
35
  This will add the <tt>minitest_helper.rb</tt> file to the <tt>test</tt> directory.
36
36
 
37
37
  == Usage
38
38
 
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.
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
41
  You can generate test files with the standard model, controller, scaffold, and other generators:
42
42
 
43
43
  rails generate model User
44
44
 
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:
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:
46
46
 
47
47
  rails generate model User --spec
48
48
 
@@ -53,5 +53,5 @@ And you can specify generating the fixture for a model by providing the <tt>--fi
53
53
  You can also set these as defaults by adding the following to the <tt>config/application.rb</tt> file:
54
54
 
55
55
  config.generators do |g|
56
- g.test_framework :minitest, :spec => true, :fixture => true
56
+ g.test_framework :mini_test, :spec => true, :fixture => true
57
57
  end
data/Rakefile CHANGED
@@ -10,15 +10,15 @@ 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']
21
+ extra_deps << ['minitest', '~> 3.0']
22
22
  extra_deps << ['rails', '~> 3.1']
23
23
  end
24
24
 
@@ -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
@@ -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 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
 
@@ -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 -%>
@@ -1,9 +1,9 @@
1
- require "generators/minitest"
1
+ require "generators/mini_test"
2
2
 
3
- module Minitest
3
+ module MiniTest
4
4
  module Generators
5
5
  class HelperGenerator < Base
6
- class_option :spec, :type => :boolean, :default => false, :desc => "Use Minitest::Spec DSL"
6
+ class_option :spec, :type => :boolean, :default => false, :desc => "Use MiniTest::Spec DSL"
7
7
 
8
8
  check_class_collision :suffix => "HelperTest"
9
9
 
@@ -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::Helper
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,15 @@
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 awesome colorful output
8
+ # require "minitest/pride"
9
+
10
+ # Do you want all existing Rails tests to use MiniTest::Rails?
11
+ # Comment out the following and either:
12
+ # A) Change the require on the existing tests to `require "minitest_helper"`
13
+ # B) Require this file's code in test_helper.rb
14
+
15
+ # ::ActiveSupport::TestCase = MiniTest::Rails::ActiveSupport::TestCase
@@ -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/integration', class_path, "#{file_name}_test.rb")
13
+ else
14
+ template 'integration_test.rb', File.join('test/integration', 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 "Integration Test"
4
+ describe "<%= class_name %> Integration 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
6
  argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
7
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"
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 -%>
@@ -1,12 +1,12 @@
1
- require "generators/minitest"
1
+ require "generators/mini_test"
2
2
  require "rails/generators/resource_helpers"
3
3
 
4
- module Minitest
4
+ module MiniTest
5
5
  module Generators
6
6
  class ScaffoldGenerator < Base
7
7
  include ::Rails::Generators::ResourceHelpers
8
8
  argument :actions, :type => :array, :default => [], :banner => "action action"
9
- class_option :spec, :type => :boolean, :default => false, :desc => "Use Minitest::Spec DSL"
9
+ class_option :spec, :type => :boolean, :default => false, :desc => "Use MiniTest::Spec DSL"
10
10
 
11
11
  check_class_collision :suffix => "ControllerTest"
12
12
 
@@ -3,12 +3,8 @@ require "minitest_helper"
3
3
  <% module_namespacing do -%>
4
4
  describe <%= class_name %>Controller do
5
5
 
6
- subject { <%= class_name %>Controller }
7
-
8
- # fixtures :all
9
-
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 <%= 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,13 +1,13 @@
1
1
  require "rails"
2
2
  require "minitest/unit"
3
3
 
4
- module Minitest
4
+ module MiniTest
5
5
  module Rails
6
- VERSION = "0.0.7"
6
+ VERSION = "0.1.0.alpha"
7
7
  class Railtie < ::Rails::Railtie
8
- # config.app_generators.integration_tool :minitest
9
- config.app_generators.test_framework :minitest
10
- config.app_generators.fallbacks[:minitest] = :test_unit
8
+ config.app_generators.integration_tool :mini_test
9
+ config.app_generators.test_framework :mini_test
10
+ config.app_generators.fallbacks[:mini_test] = :test_unit
11
11
 
12
12
  rake_tasks do
13
13
  load "minitest/rails/tasks/minitest.rake"