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.
- data/Manifest.txt +27 -25
- data/README.rdoc +6 -6
- data/Rakefile +3 -3
- data/lib/generators/{minitest.rb → mini_test.rb} +2 -2
- data/lib/generators/{minitest → mini_test}/controller/controller_generator.rb +3 -3
- data/lib/generators/{minitest/controller/templates/controller_test.rb → mini_test/controller/templates/controller_spec.rb} +6 -7
- data/lib/generators/mini_test/controller/templates/controller_test.rb +19 -0
- data/lib/generators/{minitest → mini_test}/helper/helper_generator.rb +3 -3
- data/lib/generators/{minitest → mini_test}/helper/templates/helper_spec.rb +0 -0
- data/lib/generators/{minitest → mini_test}/helper/templates/helper_test.rb +1 -1
- data/lib/generators/{minitest → mini_test}/install/install_generator.rb +1 -1
- data/lib/generators/mini_test/install/templates/test/minitest_helper.rb +15 -0
- data/lib/generators/mini_test/integration/integration_generator.rb +19 -0
- data/lib/generators/mini_test/integration/templates/integration_spec.rb +8 -0
- data/lib/generators/mini_test/integration/templates/integration_test.rb +7 -0
- data/lib/generators/{minitest → mini_test}/mailer/mailer_generator.rb +3 -3
- data/lib/generators/{minitest → mini_test}/mailer/templates/mailer_spec.rb +2 -2
- data/lib/generators/{minitest → mini_test}/mailer/templates/mailer_test.rb +5 -5
- data/lib/generators/{minitest → mini_test}/model/model_generator.rb +3 -3
- data/lib/generators/{minitest → mini_test}/model/templates/fixtures.yml +0 -0
- data/lib/generators/mini_test/model/templates/model_spec.rb +13 -0
- data/lib/generators/mini_test/model/templates/model_test.rb +9 -0
- data/lib/generators/{minitest → mini_test}/scaffold/scaffold_generator.rb +3 -3
- data/lib/generators/{minitest → mini_test}/scaffold/templates/controller_spec.rb +1 -5
- data/lib/generators/{minitest → mini_test}/scaffold/templates/controller_test.rb +3 -2
- data/lib/minitest-rails.rb +5 -5
- data/lib/minitest/rails.rb +40 -5
- data/lib/minitest/rails/action_controller.rb +17 -0
- data/lib/minitest/rails/action_dispatch.rb +21 -0
- data/lib/minitest/rails/action_mailer.rb +17 -0
- data/lib/minitest/rails/active_support.rb +62 -0
- data/lib/minitest/rails/tasks/minitest.rake +1 -1
- data/minitest-rails.gemspec +42 -0
- data/test/test_controller_generator.rb +5 -10
- data/test/test_helper_generator.rb +5 -5
- data/test/test_install_generator.rb +5 -13
- data/test/test_mailer_generator.rb +5 -6
- data/test/test_minitest.rb +2 -2
- data/test/test_model_generator.rb +5 -7
- data/test/test_scaffold_generator.rb +5 -8
- metadata +43 -41
- data/lib/generators/minitest/controller/templates/controller_spec.rb +0 -17
- data/lib/generators/minitest/install/templates/test/minitest_helper.rb +0 -61
- data/lib/generators/minitest/model/templates/model_spec.rb +0 -28
- data/lib/generators/minitest/model/templates/model_test.rb +0 -11
- data/lib/minitest/rails/controller.rb +0 -104
- data/lib/minitest/rails/fixtures.rb +0 -14
- data/lib/minitest/rails/helper.rb +0 -30
- data/lib/minitest/rails/mailer.rb +0 -8
- data/lib/minitest/rails/model.rb +0 -8
- 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/
|
7
|
-
lib/generators/
|
8
|
-
lib/generators/
|
9
|
-
lib/generators/
|
10
|
-
lib/generators/
|
11
|
-
lib/generators/
|
12
|
-
lib/generators/
|
13
|
-
lib/generators/
|
14
|
-
lib/generators/
|
15
|
-
lib/generators/
|
16
|
-
lib/generators/
|
17
|
-
lib/generators/
|
18
|
-
lib/generators/
|
19
|
-
lib/generators/
|
20
|
-
lib/generators/
|
21
|
-
lib/generators/
|
22
|
-
lib/generators/
|
23
|
-
lib/generators/
|
24
|
-
lib/generators/
|
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/
|
28
|
-
lib/minitest/rails/
|
29
|
-
lib/minitest/rails/
|
30
|
-
lib/minitest/rails/
|
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
|
-
|
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
|
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
|
40
|
-
Your test classes will inherit from
|
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
|
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 :
|
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 = '
|
14
|
-
self.description = 'Adds
|
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', '~>
|
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
|
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__), '
|
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/
|
1
|
+
require "generators/mini_test"
|
2
2
|
|
3
|
-
module
|
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
|
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
|
-
|
5
|
-
|
4
|
+
describe <%= class_name %>Controller do
|
6
5
|
<% if actions.empty? -%>
|
7
|
-
|
8
|
-
|
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
|
-
|
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/
|
1
|
+
require "generators/mini_test"
|
2
2
|
|
3
|
-
module
|
3
|
+
module MiniTest
|
4
4
|
module Generators
|
5
5
|
class HelperGenerator < Base
|
6
|
-
class_option :spec, :type => :boolean, :default => false, :desc => "Use
|
6
|
+
class_option :spec, :type => :boolean, :default => false, :desc => "Use MiniTest::Spec DSL"
|
7
7
|
|
8
8
|
check_class_collision :suffix => "HelperTest"
|
9
9
|
|
File without changes
|
@@ -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
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require "generators/
|
1
|
+
require "generators/mini_test"
|
2
2
|
|
3
|
-
module
|
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
|
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 <
|
4
|
+
class <%= class_name %>Test < MiniTest::Rails::ActionMailer::TestCase
|
5
5
|
<% actions.each do |action| -%>
|
6
|
-
|
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
|
-
|
17
|
-
|
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/
|
1
|
+
require "generators/mini_test"
|
2
2
|
|
3
|
-
module
|
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
|
8
|
+
class_option :spec, :type => :boolean, :default => false, :desc => "Use MiniTest::Spec DSL"
|
9
9
|
|
10
10
|
check_class_collision :suffix => "Test"
|
11
11
|
|
File without changes
|
@@ -1,12 +1,12 @@
|
|
1
|
-
require "generators/
|
1
|
+
require "generators/mini_test"
|
2
2
|
require "rails/generators/resource_helpers"
|
3
3
|
|
4
|
-
module
|
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
|
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 %> = <%=
|
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 <
|
4
|
+
class <%= class_name %>ControllerTest < MiniTest::Rails::ActionController::TestCase
|
5
|
+
|
5
6
|
before do
|
6
|
-
@<%= singular_table_name %> = <%=
|
7
|
+
@<%= singular_table_name %> = <%= class_name %>.new
|
7
8
|
end
|
8
9
|
|
9
10
|
def test_index
|
data/lib/minitest-rails.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
require "rails"
|
2
2
|
require "minitest/unit"
|
3
3
|
|
4
|
-
module
|
4
|
+
module MiniTest
|
5
5
|
module Rails
|
6
|
-
VERSION = "0.0.
|
6
|
+
VERSION = "0.1.0.alpha"
|
7
7
|
class Railtie < ::Rails::Railtie
|
8
|
-
|
9
|
-
config.app_generators.test_framework :
|
10
|
-
config.app_generators.fallbacks[:
|
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"
|