minitest-rails 0.3 → 0.5
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.
- data/.travis.yml +4 -2
- data/LICENSE +1 -1
- data/Manifest.txt +5 -8
- data/README.rdoc +11 -29
- data/Rakefile +3 -3
- data/gemfiles/3.0.gemfile +1 -1
- data/gemfiles/3.0.gemfile.lock +35 -35
- data/gemfiles/3.1.gemfile +1 -1
- data/gemfiles/3.1.gemfile.lock +35 -35
- data/gemfiles/3.2.gemfile +1 -1
- data/gemfiles/3.2.gemfile.lock +39 -38
- data/gemfiles/4.0.gemfile +8 -0
- data/gemfiles/4.0.gemfile.lock +104 -0
- data/lib/generators/mini_test.rb +25 -12
- data/lib/generators/mini_test/controller/templates/controller_test.rb +1 -1
- data/lib/generators/mini_test/helper/templates/helper_test.rb +2 -2
- data/lib/generators/mini_test/install/install_generator.rb +1 -1
- data/lib/generators/mini_test/install/templates/test/minitest_helper.rb +3 -9
- data/lib/generators/mini_test/integration/integration_generator.rb +2 -2
- data/lib/generators/mini_test/integration/templates/integration_spec.rb +2 -2
- data/lib/generators/mini_test/integration/templates/integration_test.rb +1 -1
- data/lib/generators/mini_test/mailer/templates/mailer_test.rb +1 -1
- data/lib/generators/mini_test/model/templates/model_test.rb +1 -1
- data/lib/generators/mini_test/scaffold/templates/controller_test.rb +1 -1
- data/lib/minitest/rails.rb +109 -20
- data/lib/minitest/rails/constant_lookup.rb +41 -44
- data/lib/minitest/rails/tasks/minitest.rake +22 -51
- data/lib/minitest/rails/test_case.rb +93 -0
- data/lib/minitest/rails/testing.rb +39 -0
- data/lib/minitest/rails/version.rb +1 -1
- data/minitest-rails.gemspec +11 -11
- data/tasks/gemfiles.rake +2 -1
- data/tasks/test.rake +6 -0
- data/test/generators/test_controller_generator.rb +10 -39
- data/test/generators/test_helper_generator.rb +8 -35
- data/test/generators/test_install_generator.rb +4 -27
- data/test/generators/test_mailer_generator.rb +5 -29
- data/test/generators/test_model_generator.rb +7 -32
- data/test/generators/test_scaffold_generator.rb +5 -29
- data/test/helper.rb +35 -0
- data/test/rails/action_controller/test_controllers.rb +4 -14
- data/test/rails/action_controller/test_spec_type.rb +3 -7
- data/test/rails/action_dispatch/test_spec_type.rb +16 -11
- data/test/rails/action_mailer/test_mailers.rb +4 -8
- data/test/rails/action_mailer/test_spec_type.rb +3 -8
- data/test/rails/action_view/test_helpers.rb +4 -7
- data/test/rails/action_view/test_spec_type.rb +3 -10
- data/test/rails/active_support/test_spec_type.rb +2 -7
- data/test/rails/test_constant_lookup.rb +2 -5
- data/test/test_sanity.rb +1 -2
- metadata +33 -36
- data/gemfiles/minitest_tu_shim.rb +0 -4
- data/lib/minitest/rails/action_controller.rb +0 -28
- data/lib/minitest/rails/action_dispatch.rb +0 -41
- data/lib/minitest/rails/action_mailer.rb +0 -26
- data/lib/minitest/rails/action_view.rb +0 -23
- data/lib/minitest/rails/active_support.rb +0 -70
- data/lib/minitest/rails/declarative.rb +0 -27
- data/lib/minitest/rails/mochaing.rb +0 -11
@@ -0,0 +1,104 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git://github.com/rails/rails.git
|
3
|
+
revision: 0fe64f4273d055f4fbca866ea6e05bf05a76a31c
|
4
|
+
specs:
|
5
|
+
actionmailer (4.0.0.beta)
|
6
|
+
actionpack (= 4.0.0.beta)
|
7
|
+
mail (~> 2.5.3)
|
8
|
+
actionpack (4.0.0.beta)
|
9
|
+
activesupport (= 4.0.0.beta)
|
10
|
+
builder (~> 3.1.0)
|
11
|
+
erubis (~> 2.7.0)
|
12
|
+
rack (~> 1.4.3)
|
13
|
+
rack-test (~> 0.6.1)
|
14
|
+
activemodel (4.0.0.beta)
|
15
|
+
activesupport (= 4.0.0.beta)
|
16
|
+
builder (~> 3.1.0)
|
17
|
+
activerecord (4.0.0.beta)
|
18
|
+
activemodel (= 4.0.0.beta)
|
19
|
+
activerecord-deprecated_finders (= 0.0.1)
|
20
|
+
activesupport (= 4.0.0.beta)
|
21
|
+
arel (~> 3.0.2)
|
22
|
+
activesupport (4.0.0.beta)
|
23
|
+
i18n (~> 0.6)
|
24
|
+
minitest (~> 4.1)
|
25
|
+
multi_json (~> 1.3)
|
26
|
+
thread_safe (~> 0.1)
|
27
|
+
tzinfo (~> 0.3.33)
|
28
|
+
rails (4.0.0.beta)
|
29
|
+
actionmailer (= 4.0.0.beta)
|
30
|
+
actionpack (= 4.0.0.beta)
|
31
|
+
activerecord (= 4.0.0.beta)
|
32
|
+
activesupport (= 4.0.0.beta)
|
33
|
+
bundler (>= 1.3.0.pre.4, < 2.0)
|
34
|
+
railties (= 4.0.0.beta)
|
35
|
+
sprockets-rails (~> 2.0.0.rc1)
|
36
|
+
railties (4.0.0.beta)
|
37
|
+
actionpack (= 4.0.0.beta)
|
38
|
+
activesupport (= 4.0.0.beta)
|
39
|
+
rake (>= 0.8.7)
|
40
|
+
rdoc (~> 3.4)
|
41
|
+
thor (>= 0.15.4, < 2.0)
|
42
|
+
|
43
|
+
PATH
|
44
|
+
remote: /Users/blowmage/codez/minitest-rails
|
45
|
+
specs:
|
46
|
+
minitest-rails (0.5.20130110235401)
|
47
|
+
minitest (~> 4.0)
|
48
|
+
rails (>= 3.0)
|
49
|
+
|
50
|
+
GEM
|
51
|
+
remote: http://rubygems.org/
|
52
|
+
specs:
|
53
|
+
activerecord-deprecated_finders (0.0.1)
|
54
|
+
arel (3.0.2)
|
55
|
+
atomic (1.0.1)
|
56
|
+
builder (3.1.4)
|
57
|
+
erubis (2.7.0)
|
58
|
+
fakefs (0.4.2)
|
59
|
+
hike (1.2.1)
|
60
|
+
hoe (3.4.0)
|
61
|
+
rake (>= 0.8, < 11.0)
|
62
|
+
i18n (0.6.1)
|
63
|
+
json (1.7.6)
|
64
|
+
mail (2.5.3)
|
65
|
+
i18n (>= 0.4.0)
|
66
|
+
mime-types (~> 1.16)
|
67
|
+
treetop (~> 1.4.8)
|
68
|
+
mime-types (1.19)
|
69
|
+
minitest (4.4.0)
|
70
|
+
multi_json (1.5.0)
|
71
|
+
polyglot (0.3.3)
|
72
|
+
rack (1.4.3)
|
73
|
+
rack-test (0.6.2)
|
74
|
+
rack (>= 1.0)
|
75
|
+
rake (10.0.3)
|
76
|
+
rdoc (3.12)
|
77
|
+
json (~> 1.4)
|
78
|
+
sprockets (2.8.2)
|
79
|
+
hike (~> 1.2)
|
80
|
+
multi_json (~> 1.0)
|
81
|
+
rack (~> 1.0)
|
82
|
+
tilt (~> 1.1, != 1.3.0)
|
83
|
+
sprockets-rails (2.0.0.rc1)
|
84
|
+
actionpack (>= 3.0)
|
85
|
+
activesupport (>= 3.0)
|
86
|
+
sprockets (~> 2.8)
|
87
|
+
thor (0.16.0)
|
88
|
+
thread_safe (0.1.0)
|
89
|
+
atomic
|
90
|
+
tilt (1.3.3)
|
91
|
+
treetop (1.4.12)
|
92
|
+
polyglot
|
93
|
+
polyglot (>= 0.3.1)
|
94
|
+
tzinfo (0.3.35)
|
95
|
+
|
96
|
+
PLATFORMS
|
97
|
+
ruby
|
98
|
+
|
99
|
+
DEPENDENCIES
|
100
|
+
fakefs (~> 0.4)
|
101
|
+
hoe (~> 3.0)
|
102
|
+
minitest-rails!
|
103
|
+
rails!
|
104
|
+
rdoc (~> 3.10)
|
data/lib/generators/mini_test.rb
CHANGED
@@ -3,24 +3,37 @@ require 'rails/generators/named_base'
|
|
3
3
|
module MiniTest
|
4
4
|
module Generators
|
5
5
|
class Base < ::Rails::Generators::NamedBase #:nodoc:
|
6
|
+
|
7
|
+
class_option :old_style_hash, :type => :boolean, :default => false,
|
8
|
+
:desc => "Force using old style hash (:foo => 'bar') on Ruby >= 1.9"
|
9
|
+
|
6
10
|
def self.source_root
|
7
11
|
@_minitest_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'mini_test', generator_name, 'templates'))
|
8
12
|
end
|
9
13
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
14
|
+
protected
|
15
|
+
|
16
|
+
# Fill in methods that might be missing depending on the version of Rails
|
17
|
+
|
18
|
+
def module_namespacing(&block)
|
19
|
+
yield if block_given?
|
20
|
+
end unless respond_to? :module_namespacing
|
21
|
+
|
22
|
+
def key_value(key, value)
|
23
|
+
if options[:old_style_hash] || RUBY_VERSION < '1.9'
|
24
|
+
":#{key} => #{value}"
|
25
|
+
else
|
26
|
+
"#{key}: #{value}"
|
15
27
|
end
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
28
|
+
end unless respond_to? :key_value
|
29
|
+
|
30
|
+
def attributes_names
|
31
|
+
@attributes_names ||= attributes.each_with_object([]) do |a, names|
|
32
|
+
names << a.column_name
|
33
|
+
names << "#{a.name}_type" if a.polymorphic?
|
22
34
|
end
|
23
|
-
end
|
35
|
+
end unless respond_to? :attributes_names
|
36
|
+
|
24
37
|
end
|
25
38
|
end
|
26
39
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "minitest_helper"
|
2
2
|
|
3
3
|
<% module_namespacing do -%>
|
4
|
-
class <%= class_name %>ControllerTest <
|
4
|
+
class <%= class_name %>ControllerTest < ActionController::TestCase
|
5
5
|
<% if actions.empty? -%>
|
6
6
|
# test "the truth" do
|
7
7
|
# assert true
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require "minitest_helper"
|
2
2
|
|
3
3
|
<% module_namespacing do -%>
|
4
|
-
class <%= class_name %>HelperTest <
|
4
|
+
class <%= class_name %>HelperTest < ActionView::TestCase
|
5
5
|
|
6
6
|
def test_sanity
|
7
|
-
|
7
|
+
assert true
|
8
8
|
end
|
9
9
|
|
10
10
|
end
|
@@ -4,22 +4,16 @@ require File.expand_path('../../config/environment', __FILE__)
|
|
4
4
|
require "minitest/autorun"
|
5
5
|
require "minitest/rails"
|
6
6
|
|
7
|
-
#
|
7
|
+
# Add `gem "minitest/rails/capybara"` to the test group of your Gemfile
|
8
|
+
# and uncomment the following if you want Capybara feature tests
|
8
9
|
# require "minitest/rails/capybara"
|
9
10
|
|
10
11
|
# Uncomment if you want awesome colorful output
|
11
12
|
# require "minitest/pride"
|
12
13
|
|
13
|
-
class
|
14
|
+
class ActiveSupport::TestCase
|
14
15
|
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
|
15
16
|
fixtures :all
|
16
17
|
|
17
18
|
# Add more helper methods to be used by all tests here...
|
18
19
|
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!
|
@@ -9,9 +9,9 @@ module MiniTest
|
|
9
9
|
|
10
10
|
def create_test_files
|
11
11
|
if options[:spec]
|
12
|
-
template 'integration_spec.rb', File.join('test/
|
12
|
+
template 'integration_spec.rb', File.join('test/integration', class_path, "#{file_name}_test.rb")
|
13
13
|
else
|
14
|
-
template 'integration_test.rb', File.join('test/
|
14
|
+
template 'integration_test.rb', File.join('test/integration', class_path, "#{file_name}_test.rb")
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "minitest_helper"
|
2
2
|
|
3
|
-
# To be handled correctly this spec must end with "
|
4
|
-
describe "<%= class_name %>
|
3
|
+
# To be handled correctly this spec must end with "Integration Test"
|
4
|
+
describe "<%= class_name %> Integration Test" do
|
5
5
|
# it "must be a real test" do
|
6
6
|
# flunk "Need real tests"
|
7
7
|
# end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "minitest_helper"
|
2
2
|
|
3
3
|
<% module_namespacing do -%>
|
4
|
-
class <%= class_name %>Test <
|
4
|
+
class <%= class_name %>Test < ActionMailer::TestCase
|
5
5
|
<% actions.each do |action| -%>
|
6
6
|
test "<%= action %>" do
|
7
7
|
mail = <%= class_name %>.<%= action %>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "minitest_helper"
|
2
2
|
|
3
3
|
<% module_namespacing do -%>
|
4
|
-
class <%= controller_class_name %>ControllerTest <
|
4
|
+
class <%= controller_class_name %>ControllerTest < ActionController::TestCase
|
5
5
|
|
6
6
|
before do
|
7
7
|
@<%= singular_table_name %> = <%= table_name %>(:one)
|
data/lib/minitest/rails.rb
CHANGED
@@ -2,53 +2,142 @@
|
|
2
2
|
# so fixtures aren't loaded into that environment
|
3
3
|
abort("Abort testing: Your Rails environment is running in production mode!") if Rails.env.production?
|
4
4
|
|
5
|
-
require "minitest/rails/
|
6
|
-
require "minitest/rails/action_controller"
|
7
|
-
require "minitest/rails/action_view"
|
8
|
-
require "minitest/rails/action_mailer" if defined? ActionMailer
|
9
|
-
require "minitest/rails/action_dispatch"
|
5
|
+
require "minitest/rails/test_case"
|
10
6
|
|
11
7
|
# Enable turn if it is available
|
12
8
|
begin
|
13
|
-
require
|
9
|
+
require "turn/autorun"
|
14
10
|
rescue LoadError
|
15
11
|
end
|
16
12
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
13
|
+
# Override the default ActiveSupport::TestCase to set the minitest dependency
|
14
|
+
|
15
|
+
require "active_support/test_case"
|
16
|
+
Kernel.silence_warnings do
|
17
|
+
ActiveSupport.const_set :TestCase, MiniTest::Rails::TestCase
|
18
|
+
end
|
19
|
+
|
20
|
+
# Add spec DSL integration
|
21
|
+
|
22
|
+
if defined?(ActiveRecord::Base)
|
23
|
+
class ActiveSupport::TestCase
|
24
|
+
# Use AS::TestCase for the base class when describing a model
|
25
|
+
register_spec_type(self) do |desc|
|
26
|
+
desc < ActiveRecord::Base if desc.is_a?(Class)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
require "action_controller/test_case"
|
32
|
+
class ActionController::TestCase
|
33
|
+
# Use AC::TestCase for the base class when describing a controller
|
34
|
+
register_spec_type(self) do |desc|
|
35
|
+
Class === desc && desc < ActionController::Metal
|
36
|
+
end
|
37
|
+
register_spec_type(/Controller( ?Test)?\z/i, self)
|
38
|
+
|
39
|
+
# Resolve the controller from the test name when using the spec DSL
|
40
|
+
def self.determine_default_controller_class(name)
|
41
|
+
controller = determine_constant_from_test_name(name) do |constant|
|
42
|
+
Class === constant && constant < ActionController::Metal
|
43
|
+
end
|
44
|
+
raise NameError.new("Unable to resolve controller for #{name}") if controller.nil?
|
45
|
+
controller
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
require "action_view/test_case"
|
50
|
+
class ActionView::TestCase
|
51
|
+
# Use AV::TestCase for the base class for helpers and views
|
52
|
+
register_spec_type(/(Helper( ?Test)?| View Test)\z/i, self)
|
53
|
+
|
54
|
+
# Resolve the helper or view from the test name when using the spec DSL
|
55
|
+
def self.determine_default_helper_class(name)
|
56
|
+
determine_constant_from_test_name(name) do |constant|
|
57
|
+
Module === constant
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
if defined? ActionMailer
|
63
|
+
require "action_mailer/test_helper"
|
64
|
+
require "action_mailer/test_case"
|
65
|
+
class ActionMailer::TestCase
|
66
|
+
# Use AM::TestCase for the base class when describing a mailer
|
67
|
+
register_spec_type(self) do |desc|
|
68
|
+
desc < ActionMailer::Base if desc.is_a?(Class)
|
69
|
+
end
|
70
|
+
register_spec_type(/Mailer( ?Test)?\z/i, self)
|
71
|
+
|
72
|
+
# Resolve the mailer from the test name when using the spec DSL
|
73
|
+
def self.determine_default_mailer(name)
|
74
|
+
mailer = determine_constant_from_test_name(name) do |constant|
|
75
|
+
Class === constant && constant < ::ActionMailer::Base
|
26
76
|
end
|
77
|
+
raise ActionMailer::NonInferrableMailerError.new(name) if mailer.nil?
|
78
|
+
mailer
|
27
79
|
end
|
28
80
|
end
|
29
81
|
end
|
30
82
|
|
83
|
+
require "action_dispatch/testing/integration"
|
84
|
+
class ActionDispatch::IntegrationTest
|
85
|
+
# Register by name, consider Acceptance to be deprecated
|
86
|
+
register_spec_type(/(Integration|Acceptance)( ?Test)?\z/i, self)
|
87
|
+
end
|
88
|
+
|
89
|
+
# Default wiring for the tests. This was originaly done in the helper.
|
90
|
+
|
91
|
+
# Enable fixtures if appropriate
|
92
|
+
|
31
93
|
if defined?(ActiveRecord::Base)
|
32
|
-
class
|
94
|
+
class ActiveSupport::TestCase
|
33
95
|
include ActiveRecord::TestFixtures
|
34
96
|
self.fixture_path = "#{Rails.root}/test/fixtures/"
|
35
97
|
end
|
36
98
|
|
37
|
-
|
99
|
+
ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
|
38
100
|
|
39
101
|
def create_fixtures(*table_names, &block)
|
40
|
-
ActiveRecord::Fixtures.create_fixtures(
|
102
|
+
ActiveRecord::Fixtures.create_fixtures(ActiveSupport::TestCase.fixture_path, table_names, {}, &block)
|
41
103
|
end
|
42
104
|
end
|
43
105
|
|
44
|
-
|
106
|
+
# Setup the routes
|
107
|
+
|
108
|
+
class ActionController::TestCase
|
45
109
|
setup do
|
46
110
|
@routes = Rails.application.routes
|
47
111
|
end
|
48
112
|
end
|
49
113
|
|
50
|
-
class
|
114
|
+
class ActionDispatch::IntegrationTest
|
51
115
|
setup do
|
52
116
|
@routes = Rails.application.routes
|
53
117
|
end
|
54
118
|
end
|
119
|
+
|
120
|
+
# Deprecated, for backwards compatibility with older minitest-rails only
|
121
|
+
|
122
|
+
module MiniTest
|
123
|
+
module Rails
|
124
|
+
def self.override_testunit!
|
125
|
+
# noop
|
126
|
+
end
|
127
|
+
module ActiveSupport
|
128
|
+
TestCase = ::ActiveSupport::TestCase
|
129
|
+
end
|
130
|
+
module ActionController
|
131
|
+
TestCase = ::ActionController::TestCase
|
132
|
+
end
|
133
|
+
module ActionView
|
134
|
+
TestCase = ::ActionView::TestCase
|
135
|
+
end
|
136
|
+
module ActionMailer
|
137
|
+
TestCase = ::ActionMailer::TestCase if defined? ::ActionMailer
|
138
|
+
end
|
139
|
+
module ActionDispatch
|
140
|
+
IntegrationTest = ::ActionDispatch::IntegrationTest
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|