minitest-rails 0.9.2 → 1.0.0.beta1
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.
- checksums.yaml +7 -0
- data/.travis.yml +14 -16
- data/Gemfile +7 -0
- data/Manifest.txt +12 -9
- data/README.rdoc +13 -1
- data/Rakefile +6 -5
- data/gemfiles/3.0.gemfile +2 -5
- data/gemfiles/3.1.gemfile +2 -5
- data/gemfiles/3.2.gemfile +2 -5
- data/gemfiles/4.0.gemfile +2 -6
- data/lib/generators/.document +0 -0
- data/lib/generators/mini_test/controller/templates/controller_spec.rb +3 -3
- data/lib/generators/mini_test/controller/templates/controller_test.rb +4 -4
- data/lib/generators/mini_test/helper/templates/helper_test.rb +1 -1
- data/lib/generators/mini_test/install/install_generator.rb +5 -0
- data/lib/generators/mini_test/install/templates/test_helper.rb +9 -0
- data/lib/generators/mini_test/integration/templates/integration_spec.rb +3 -3
- data/lib/generators/mini_test/integration/templates/integration_test.rb +3 -3
- data/lib/generators/mini_test/mailer/mailer_generator.rb +2 -2
- data/lib/generators/mini_test/mailer/templates/mailer_test.rb +4 -4
- data/lib/generators/mini_test/model/model_generator.rb +3 -3
- data/lib/generators/mini_test/model/templates/model_spec.rb +2 -4
- data/lib/generators/mini_test/model/templates/model_test.rb +9 -3
- data/lib/generators/mini_test/route/templates/route_spec.rb +1 -1
- data/lib/generators/mini_test/route/templates/route_test.rb +1 -1
- data/lib/generators/mini_test/scaffold/templates/controller_spec.rb +12 -14
- data/lib/generators/mini_test/scaffold/templates/controller_test.rb +6 -6
- data/lib/minitest/rails/assertions.rb +1811 -0
- data/lib/minitest/rails/expectations.rb +659 -0
- data/lib/minitest/rails/generators.rb +18 -0
- data/lib/minitest/rails/railtie.rb +1 -1
- data/lib/minitest/rails/tasks/.document +0 -0
- data/lib/minitest/rails/tasks/minitest.rake +44 -13
- data/lib/minitest/rails/testing.rb +10 -20
- data/lib/minitest/rails/version.rb +1 -1
- data/lib/minitest/rails.rb +22 -3
- data/minitest-rails.gemspec +21 -16
- data/tasks/test.rake +27 -15
- data/test/generators/test_install_generator.rb +17 -0
- data/test/generators/test_mailer_generator.rb +19 -0
- data/test/generators/test_model_generator.rb +25 -1
- data/test/helper.rb +27 -0
- data/test/rails/action_controller/test_assertions.rb +46 -0
- data/test/rails/action_controller/test_controllers.rb +2 -13
- data/test/rails/action_controller/test_expectations.rb +45 -0
- data/test/rails/active_support/test_assertions.rb +59 -0
- data/test/rails/active_support/test_expectations.rb +49 -0
- data/test/rails/generators/test_spec_type.rb +36 -0
- data/test/rails/minitest_5_api_test.rb +8 -0
- metadata +66 -54
- data/gemfiles/3.0.gemfile.lock +0 -91
- data/gemfiles/3.1.gemfile.lock +0 -102
- data/gemfiles/3.2.gemfile.lock +0 -101
- data/gemfiles/4.0.gemfile.lock +0 -99
- data/lib/autotest/discover.rb +0 -5
- data/lib/autotest/fixtures.rb +0 -7
- data/lib/autotest/migrate.rb +0 -5
- data/lib/autotest/minitest_rails.rb +0 -63
- data/tasks/gemfiles.rake +0 -24
@@ -15,48 +15,79 @@ end
|
|
15
15
|
|
16
16
|
namespace "minitest" do
|
17
17
|
|
18
|
-
#
|
18
|
+
# Main entry point for minitest
|
19
19
|
task :default do
|
20
20
|
if ENV["TEST"]
|
21
21
|
Rake::Task["minitest:single"].invoke
|
22
22
|
else
|
23
|
-
|
23
|
+
Rake::Task["minitest:run"].invoke
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
# Run a single test
|
28
|
+
MiniTest::Rails::Tasks::SubTestTask.new(:single => "test:prepare") do |t|
|
29
|
+
t.libs << "test"
|
30
|
+
end
|
31
|
+
|
32
|
+
# Run the default tests as definded in MiniTest::Rails::Testing.default_tasks
|
33
|
+
MiniTest::Rails::Tasks::SubTestTask.new(:run => "test:prepare") do |t|
|
34
|
+
t.libs.push "test"
|
35
|
+
t.pattern = "test/{#{MiniTest::Rails::Testing.default_tasks.join(',')}}/**/*_test.rb"
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "Runs all tests"
|
39
|
+
MiniTest::Rails::Tasks::SubTestTask.new(:all => "test:prepare") do |t|
|
40
|
+
t.libs.push "test"
|
41
|
+
t.pattern = "test/**/*_test.rb"
|
30
42
|
end
|
43
|
+
|
31
44
|
namespace "all" do
|
32
|
-
desc "
|
33
|
-
MiniTest::Rails::Tasks::SubTestTask.new(:quick
|
45
|
+
desc "Runs all tests, without resetting the db"
|
46
|
+
MiniTest::Rails::Tasks::SubTestTask.new(:quick) do |t|
|
34
47
|
t.libs.push "test"
|
35
48
|
t.pattern = "test/**/*_test.rb"
|
36
49
|
end
|
37
50
|
end
|
38
51
|
|
39
|
-
|
40
|
-
t.libs << "test"
|
41
|
-
end
|
42
|
-
|
52
|
+
# Loop that will define a task for each directory that has tests
|
43
53
|
MiniTest::Rails::Testing.all_tasks.each do |task_dir|
|
44
54
|
unless Rake::Task.task_defined? "minitest:#{task_dir}"
|
45
55
|
desc "Runs tests under test/#{task_dir}"
|
46
56
|
MiniTest::Rails::Tasks::SubTestTask.new(task_dir => "test:prepare") do |t|
|
47
57
|
t.libs.push "test"
|
48
58
|
t.pattern = "test/#{task_dir}/**/*_test.rb"
|
49
|
-
t.options = MiniTest::Rails::Testing.task_opts[task_dir] if MiniTest::Rails::Testing.task_opts[task_dir]
|
50
59
|
end
|
51
60
|
end
|
52
61
|
end
|
53
62
|
|
54
63
|
end
|
55
64
|
|
65
|
+
# Statistics
|
66
|
+
|
67
|
+
# set hook on stats task
|
68
|
+
task :stats => "minitest:setup_stats"
|
69
|
+
|
70
|
+
namespace "minitest" do
|
71
|
+
task :setup_stats do
|
72
|
+
require "rails/code_statistics"
|
73
|
+
|
74
|
+
# Clear existing test directories
|
75
|
+
STATS_DIRECTORIES.reject! { |name, dir| dir.starts_with? Rails.root.join("test").to_s }
|
76
|
+
CodeStatistics::TEST_TYPES.clear
|
77
|
+
|
78
|
+
# Add test directories that minitest-rails knows about
|
79
|
+
MiniTest::Rails::Testing.all_tasks.each do |dir|
|
80
|
+
name = "#{dir.capitalize} tests"
|
81
|
+
STATS_DIRECTORIES << [ name, Rails.root.join("test").join(dir).to_s ]
|
82
|
+
CodeStatistics::TEST_TYPES << name
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
56
87
|
# Override the test task
|
57
88
|
task :test => [] # Just in case it hasn't already been set
|
58
89
|
Rake::Task[:test].clear
|
59
|
-
desc "
|
90
|
+
desc "Runs default tests"
|
60
91
|
task :test => "minitest"
|
61
92
|
|
62
93
|
# Override the default task
|
@@ -6,34 +6,24 @@ module MiniTest
|
|
6
6
|
mattr_accessor :default_tasks
|
7
7
|
mattr_accessor :task_opts
|
8
8
|
|
9
|
+
##
|
10
|
+
# The default tasks that are to be run by <tt>rake minitest</tt>.
|
11
|
+
#
|
12
|
+
# # Add test/presenters to default test task
|
13
|
+
# MiniTest::Rails::Testing.default_tasks << "presenters"
|
14
|
+
#
|
15
|
+
# Default values are: models helpers controllers mailers integration
|
16
|
+
# :attr: default_tasks
|
9
17
|
self.default_tasks = %w(models helpers controllers mailers integration)
|
10
|
-
self.task_opts = { "performance" => "-- --benchmark" }
|
11
18
|
|
19
|
+
##
|
20
|
+
# Retreive all the directories that have tests in them.
|
12
21
|
def self.all_tasks
|
13
22
|
Dir["test/*/"].map {|dir| /test\/(.+?)\//.match(dir)[1] }.select do |dir|
|
14
23
|
!Dir.glob("test/#{dir}/**/*_test.rb").empty?
|
15
24
|
end
|
16
25
|
end
|
17
26
|
|
18
|
-
def self.run_tests directories
|
19
|
-
errors = directories.collect do |dir|
|
20
|
-
task = "minitest:#{dir}"
|
21
|
-
begin
|
22
|
-
if Rake::Task.task_defined? task
|
23
|
-
Rake::Task[task].invoke
|
24
|
-
end
|
25
|
-
nil
|
26
|
-
rescue => e
|
27
|
-
{ :task => task, :exception => e }
|
28
|
-
end
|
29
|
-
end.compact
|
30
|
-
|
31
|
-
if errors.any?
|
32
|
-
puts errors.map { |e| "Errors running #{e[:task]}! #{e[:exception].inspect}" }.join("\n")
|
33
|
-
abort
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
27
|
end
|
38
28
|
end
|
39
29
|
end
|
data/lib/minitest/rails.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
gem "minitest"
|
2
|
-
require "minitest/
|
2
|
+
require "minitest/unit"
|
3
|
+
require "minitest/test"
|
4
|
+
require "minitest/spec"
|
5
|
+
require "minitest/mock"
|
6
|
+
require "minitest/autorun" unless ENV["MT_RAILS_NO_AUTORUN"]
|
3
7
|
|
4
8
|
# Call rails/test_help because previous versions of minitest-rails
|
5
9
|
# duplicated this functionality while trying to control the order
|
@@ -63,7 +67,7 @@ class ActionView::TestCase
|
|
63
67
|
# Resolve the helper or view from the test name when using the spec DSL
|
64
68
|
def self.determine_default_helper_class(name)
|
65
69
|
determine_constant_from_test_name(name) do |constant|
|
66
|
-
Module === constant
|
70
|
+
Module === constant && !(Class === constant)
|
67
71
|
end
|
68
72
|
end
|
69
73
|
end
|
@@ -95,15 +99,30 @@ class ActionDispatch::IntegrationTest
|
|
95
99
|
register_spec_type(/(Integration|Acceptance)( ?Test)?\z/i, self)
|
96
100
|
end
|
97
101
|
|
102
|
+
################################################################################
|
103
|
+
# Assertions and Expectations
|
104
|
+
################################################################################
|
105
|
+
|
106
|
+
require "minitest/rails/assertions"
|
107
|
+
require "minitest/rails/expectations"
|
108
|
+
|
109
|
+
# :stopdoc:
|
110
|
+
|
98
111
|
################################################################################
|
99
112
|
# 1.8.7 Spec DSL Support
|
100
113
|
################################################################################
|
101
114
|
|
102
115
|
if LoadError.const_defined? :REGEXPS
|
103
116
|
# Add relaxed regexp to allow whitespace so nested describes won't fail on 1.8.
|
104
|
-
LoadError::REGEXPS.unshift
|
117
|
+
LoadError::REGEXPS.unshift(/^Missing \w+ (?:file\s*)?(.+\.rb)/i)
|
105
118
|
end
|
106
119
|
|
120
|
+
################################################################################
|
121
|
+
# Run load hooks so that other gems can register spec types
|
122
|
+
################################################################################
|
123
|
+
|
124
|
+
ActiveSupport.run_load_hooks(:minitest, ActiveSupport::TestCase)
|
125
|
+
|
107
126
|
################################################################################
|
108
127
|
# Deprecated, for backwards compatibility with older minitest-rails only
|
109
128
|
# Will be removed at version 1.0
|
data/minitest-rails.gemspec
CHANGED
@@ -1,45 +1,50 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
# stub: minitest-rails 1.0.0.beta1.20131220153633 ruby lib
|
2
3
|
|
3
4
|
Gem::Specification.new do |s|
|
4
5
|
s.name = "minitest-rails"
|
5
|
-
s.version = "0.
|
6
|
+
s.version = "1.0.0.beta1.20131220153633"
|
6
7
|
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new("
|
8
|
+
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
8
9
|
s.authors = ["Mike Moore"]
|
9
|
-
s.date = "2013-
|
10
|
+
s.date = "2013-12-20"
|
10
11
|
s.description = "Adds MiniTest as the default testing library in Rails 3 and 4"
|
11
12
|
s.email = ["mike@blowmage.com"]
|
12
13
|
s.extra_rdoc_files = ["CHANGELOG.rdoc", "Manifest.txt", "README.rdoc"]
|
13
|
-
s.files = [".autotest", ".gemtest", ".travis.yml", "CHANGELOG.rdoc", "LICENSE", "Manifest.txt", "README.rdoc", "Rakefile", "gemfiles/3.0.gemfile", "gemfiles/3.
|
14
|
+
s.files = [".autotest", ".gemtest", ".travis.yml", "CHANGELOG.rdoc", "Gemfile", "LICENSE", "Manifest.txt", "README.rdoc", "Rakefile", "gemfiles/3.0.gemfile", "gemfiles/3.1.gemfile", "gemfiles/3.2.gemfile", "gemfiles/4.0.gemfile", "gemfiles/minitest_tu_shim.rb", "lib/generators/.document", "lib/generators/mini_test.rb", "lib/generators/mini_test/controller/controller_generator.rb", "lib/generators/mini_test/controller/templates/controller_spec.rb", "lib/generators/mini_test/controller/templates/controller_test.rb", "lib/generators/mini_test/helper/helper_generator.rb", "lib/generators/mini_test/helper/templates/helper_spec.rb", "lib/generators/mini_test/helper/templates/helper_test.rb", "lib/generators/mini_test/install/install_generator.rb", "lib/generators/mini_test/install/templates/test_helper.rb", "lib/generators/mini_test/integration/integration_generator.rb", "lib/generators/mini_test/integration/templates/integration_spec.rb", "lib/generators/mini_test/integration/templates/integration_test.rb", "lib/generators/mini_test/mailer/mailer_generator.rb", "lib/generators/mini_test/mailer/templates/mailer_spec.rb", "lib/generators/mini_test/mailer/templates/mailer_test.rb", "lib/generators/mini_test/model/model_generator.rb", "lib/generators/mini_test/model/templates/fixtures.yml", "lib/generators/mini_test/model/templates/model_spec.rb", "lib/generators/mini_test/model/templates/model_test.rb", "lib/generators/mini_test/route/route_generator.rb", "lib/generators/mini_test/route/templates/route_spec.rb", "lib/generators/mini_test/route/templates/route_test.rb", "lib/generators/mini_test/scaffold/scaffold_generator.rb", "lib/generators/mini_test/scaffold/templates/controller_spec.rb", "lib/generators/mini_test/scaffold/templates/controller_test.rb", "lib/minitest-rails.rb", "lib/minitest/rails.rb", "lib/minitest/rails/assertions.rb", "lib/minitest/rails/constant_lookup.rb", "lib/minitest/rails/deprecated/action_controller.rb", "lib/minitest/rails/deprecated/action_dispatch.rb", "lib/minitest/rails/deprecated/action_mailer.rb", "lib/minitest/rails/deprecated/action_view.rb", "lib/minitest/rails/deprecated/active_support.rb", "lib/minitest/rails/expectations.rb", "lib/minitest/rails/generators.rb", "lib/minitest/rails/railtie.rb", "lib/minitest/rails/tasks/.document", "lib/minitest/rails/tasks/minitest.rake", "lib/minitest/rails/tasks/sub_test_task.rb", "lib/minitest/rails/testing.rb", "lib/minitest/rails/version.rb", "minitest-rails.gemspec", "tasks/test.rake", "test/generators/test_controller_generator.rb", "test/generators/test_helper_generator.rb", "test/generators/test_install_generator.rb", "test/generators/test_mailer_generator.rb", "test/generators/test_model_generator.rb", "test/generators/test_route_generator.rb", "test/generators/test_scaffold_generator.rb", "test/helper.rb", "test/rails/action_controller/test_assertions.rb", "test/rails/action_controller/test_controllers.rb", "test/rails/action_controller/test_expectations.rb", "test/rails/action_controller/test_spec_type.rb", "test/rails/action_dispatch/test_spec_type.rb", "test/rails/action_mailer/test_mailers.rb", "test/rails/action_mailer/test_spec_type.rb", "test/rails/action_view/test_helpers.rb", "test/rails/action_view/test_spec_type.rb", "test/rails/active_support/test_assertions.rb", "test/rails/active_support/test_expectations.rb", "test/rails/active_support/test_spec_type.rb", "test/rails/generators/test_spec_type.rb", "test/rails/minitest_5_api_test.rb", "test/rails/test_constant_lookup.rb", "test/test_sanity.rb"]
|
14
15
|
s.homepage = "http://blowmage.com/minitest-rails"
|
16
|
+
s.licenses = ["MIT"]
|
15
17
|
s.rdoc_options = ["--main", "README.rdoc"]
|
16
18
|
s.require_paths = ["lib"]
|
17
19
|
s.rubyforge_project = "minitest-rails"
|
18
|
-
s.rubygems_version = "1.
|
20
|
+
s.rubygems_version = "2.1.11"
|
19
21
|
s.summary = "MiniTest integration for Rails 3 and 4"
|
20
|
-
s.test_files = ["test/generators/test_controller_generator.rb", "test/generators/test_helper_generator.rb", "test/generators/test_install_generator.rb", "test/generators/test_mailer_generator.rb", "test/generators/test_model_generator.rb", "test/generators/test_route_generator.rb", "test/generators/test_scaffold_generator.rb", "test/rails/action_controller/test_controllers.rb", "test/rails/action_controller/test_spec_type.rb", "test/rails/action_dispatch/test_spec_type.rb", "test/rails/action_mailer/test_mailers.rb", "test/rails/action_mailer/test_spec_type.rb", "test/rails/action_view/test_helpers.rb", "test/rails/action_view/test_spec_type.rb", "test/rails/active_support/test_spec_type.rb", "test/rails/test_constant_lookup.rb", "test/test_sanity.rb"]
|
22
|
+
s.test_files = ["test/generators/test_controller_generator.rb", "test/generators/test_helper_generator.rb", "test/generators/test_install_generator.rb", "test/generators/test_mailer_generator.rb", "test/generators/test_model_generator.rb", "test/generators/test_route_generator.rb", "test/generators/test_scaffold_generator.rb", "test/rails/action_controller/test_assertions.rb", "test/rails/action_controller/test_controllers.rb", "test/rails/action_controller/test_expectations.rb", "test/rails/action_controller/test_spec_type.rb", "test/rails/action_dispatch/test_spec_type.rb", "test/rails/action_mailer/test_mailers.rb", "test/rails/action_mailer/test_spec_type.rb", "test/rails/action_view/test_helpers.rb", "test/rails/action_view/test_spec_type.rb", "test/rails/active_support/test_assertions.rb", "test/rails/active_support/test_expectations.rb", "test/rails/active_support/test_spec_type.rb", "test/rails/generators/test_spec_type.rb", "test/rails/test_constant_lookup.rb", "test/test_sanity.rb", "test/rails/minitest_5_api_test.rb"]
|
21
23
|
|
22
24
|
if s.respond_to? :specification_version then
|
23
|
-
s.specification_version =
|
25
|
+
s.specification_version = 4
|
24
26
|
|
25
27
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
26
28
|
s.add_runtime_dependency(%q<minitest>, ["~> 4.7"])
|
27
|
-
s.add_runtime_dependency(%q<
|
28
|
-
s.
|
29
|
+
s.add_runtime_dependency(%q<minitest-test>, ["~> 1.0"])
|
30
|
+
s.add_runtime_dependency(%q<railties>, [">= 3.0"])
|
31
|
+
s.add_development_dependency(%q<rdoc>, ["~> 4.0"])
|
29
32
|
s.add_development_dependency(%q<fakefs>, ["~> 0.4"])
|
30
|
-
s.add_development_dependency(%q<hoe>, ["~> 3.
|
33
|
+
s.add_development_dependency(%q<hoe>, ["~> 3.7"])
|
31
34
|
else
|
32
35
|
s.add_dependency(%q<minitest>, ["~> 4.7"])
|
33
|
-
s.add_dependency(%q<
|
34
|
-
s.add_dependency(%q<
|
36
|
+
s.add_dependency(%q<minitest-test>, ["~> 1.0"])
|
37
|
+
s.add_dependency(%q<railties>, [">= 3.0"])
|
38
|
+
s.add_dependency(%q<rdoc>, ["~> 4.0"])
|
35
39
|
s.add_dependency(%q<fakefs>, ["~> 0.4"])
|
36
|
-
s.add_dependency(%q<hoe>, ["~> 3.
|
40
|
+
s.add_dependency(%q<hoe>, ["~> 3.7"])
|
37
41
|
end
|
38
42
|
else
|
39
43
|
s.add_dependency(%q<minitest>, ["~> 4.7"])
|
40
|
-
s.add_dependency(%q<
|
41
|
-
s.add_dependency(%q<
|
44
|
+
s.add_dependency(%q<minitest-test>, ["~> 1.0"])
|
45
|
+
s.add_dependency(%q<railties>, [">= 3.0"])
|
46
|
+
s.add_dependency(%q<rdoc>, ["~> 4.0"])
|
42
47
|
s.add_dependency(%q<fakefs>, ["~> 0.4"])
|
43
|
-
s.add_dependency(%q<hoe>, ["~> 3.
|
48
|
+
s.add_dependency(%q<hoe>, ["~> 3.7"])
|
44
49
|
end
|
45
50
|
end
|
data/tasks/test.rake
CHANGED
@@ -1,26 +1,38 @@
|
|
1
1
|
namespace :test do
|
2
|
-
desc "Run tests
|
3
|
-
task "
|
4
|
-
ENV["
|
5
|
-
sh "bundle exec rake test"
|
2
|
+
desc "Run tests for Rails 4.0"
|
3
|
+
task "4.0" do
|
4
|
+
ENV["RAILS_VERSION"] = "4.0"
|
5
|
+
sh "bundle && bundle exec rake test"
|
6
|
+
sh "rm Gemfile.lock"
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "Run tests for Rails 3.2"
|
10
|
+
task "3.2" do
|
11
|
+
ENV["RAILS_VERSION"] = "3.2"
|
12
|
+
sh "bundle && bundle exec rake test"
|
13
|
+
sh "rm Gemfile.lock"
|
6
14
|
end
|
7
15
|
|
8
|
-
desc "Run tests
|
16
|
+
desc "Run tests for Rails 3.1"
|
9
17
|
task "3.1" do
|
10
|
-
ENV["
|
11
|
-
sh "bundle exec rake test"
|
18
|
+
ENV["RAILS_VERSION"] = "3.1"
|
19
|
+
sh "bundle && bundle exec rake test"
|
20
|
+
sh "rm Gemfile.lock"
|
12
21
|
end
|
13
22
|
|
14
|
-
desc "Run tests
|
15
|
-
task "3.
|
16
|
-
ENV["
|
17
|
-
sh "bundle exec rake test"
|
23
|
+
desc "Run tests for Rails 3.0"
|
24
|
+
task "3.0" do
|
25
|
+
ENV["RAILS_VERSION"] = "3.0"
|
26
|
+
sh "bundle && bundle exec rake test"
|
27
|
+
sh "rm Gemfile.lock"
|
18
28
|
end
|
19
29
|
|
20
|
-
desc "Run tests
|
21
|
-
task "
|
22
|
-
|
23
|
-
sh "
|
30
|
+
desc "Run tests for all Rails versions"
|
31
|
+
task "all" do
|
32
|
+
sh "rake test:4.0"
|
33
|
+
sh "rake test:3.2"
|
34
|
+
sh "rake test:3.1"
|
35
|
+
sh "rake test:3.0"
|
24
36
|
end
|
25
37
|
end
|
26
38
|
|
@@ -11,6 +11,23 @@ class TestInstallGenerator < GeneratorTest
|
|
11
11
|
contents = File.read "test/test_helper.rb"
|
12
12
|
assert_match(/require "rails\/test_help"/m, contents)
|
13
13
|
assert_match(/require "minitest\/rails"/m, contents)
|
14
|
+
assert_match(/fixtures :all/m, contents)
|
15
|
+
if Rails::VERSION::STRING >= "4.0"
|
16
|
+
assert_match(/ActiveRecord::Migration.check_pending\!/m, contents)
|
17
|
+
else
|
18
|
+
refute_match(/ActiveRecord::Migration.check_pending\!/m, contents)
|
19
|
+
end
|
14
20
|
end
|
15
21
|
|
22
|
+
def test_install_generator_without_active_record
|
23
|
+
assert_output(/create test\/test_helper.rb/m) do
|
24
|
+
MiniTest::Generators::InstallGenerator.start ["--skip-active-record"]
|
25
|
+
end
|
26
|
+
assert File.exists? "test/test_helper.rb"
|
27
|
+
contents = File.read "test/test_helper.rb"
|
28
|
+
assert_match(/require "rails\/test_help"/m, contents)
|
29
|
+
assert_match(/require "minitest\/rails"/m, contents)
|
30
|
+
refute_match(/fixtures :all/m, contents)
|
31
|
+
refute_match(/ActiveRecord::Migration.check_pending\!/m, contents)
|
32
|
+
end
|
16
33
|
end
|
@@ -12,6 +12,15 @@ class TestMailerGenerator < GeneratorTest
|
|
12
12
|
assert_match(/class NotificationTest/m, contents)
|
13
13
|
end
|
14
14
|
|
15
|
+
def test_namespaced_mailer_generator
|
16
|
+
assert_output(/create test\/mailers\/admin\/notification_test.rb/m) do
|
17
|
+
MiniTest::Generators::MailerGenerator.start ["admin/notification"]
|
18
|
+
end
|
19
|
+
assert File.exists? "test/mailers/admin/notification_test.rb"
|
20
|
+
contents = File.read "test/mailers/admin/notification_test.rb"
|
21
|
+
assert_match(/class Admin::NotificationTest/m, contents)
|
22
|
+
end
|
23
|
+
|
15
24
|
def test_mailer_generator_spec
|
16
25
|
assert_output(/create test\/mailers\/notification_test.rb/m) do
|
17
26
|
MiniTest::Generators::MailerGenerator.start ["notification", "welcome", "--spec"]
|
@@ -21,4 +30,14 @@ class TestMailerGenerator < GeneratorTest
|
|
21
30
|
assert_match(/describe Notification do/m, contents)
|
22
31
|
end
|
23
32
|
|
33
|
+
def test_namespaced_mailer_generator_spec
|
34
|
+
assert_output(/create test\/mailers\/admin\/notification_test.rb/m) do
|
35
|
+
MiniTest::Generators::MailerGenerator.start ["admin/notification", "welcome", "--spec"]
|
36
|
+
end
|
37
|
+
assert File.exists? "test/mailers/admin/notification_test.rb"
|
38
|
+
contents = File.read "test/mailers/admin/notification_test.rb"
|
39
|
+
assert_match(/describe Admin::Notification do/m, contents)
|
40
|
+
end
|
41
|
+
|
42
|
+
|
24
43
|
end
|
@@ -12,6 +12,15 @@ class TestModelGenerator < GeneratorTest
|
|
12
12
|
assert_match(/class UserTest/m, contents)
|
13
13
|
end
|
14
14
|
|
15
|
+
def test_namespaced_model_generator
|
16
|
+
assert_output(/create test\/models\/admin\/user_test.rb/m) do
|
17
|
+
MiniTest::Generators::ModelGenerator.start ["admin/user"]
|
18
|
+
end
|
19
|
+
assert File.exists? "test/models/admin/user_test.rb"
|
20
|
+
contents = File.read "test/models/admin/user_test.rb"
|
21
|
+
assert_match(/class Admin::UserTest/m, contents)
|
22
|
+
end
|
23
|
+
|
15
24
|
def test_model_generator_spec
|
16
25
|
assert_output(/create test\/models\/user_test.rb/m) do
|
17
26
|
MiniTest::Generators::ModelGenerator.start ["user", "--spec"]
|
@@ -22,6 +31,15 @@ class TestModelGenerator < GeneratorTest
|
|
22
31
|
assert_match(/describe User do/m, contents)
|
23
32
|
end
|
24
33
|
|
34
|
+
def test_namespaced_model_generator_spec
|
35
|
+
assert_output(/create test\/models\/admin\/user_test.rb/m) do
|
36
|
+
MiniTest::Generators::ModelGenerator.start ["admin/user", "--spec"]
|
37
|
+
end
|
38
|
+
assert File.exists? "test/models/admin/user_test.rb"
|
39
|
+
contents = File.read "test/models/admin/user_test.rb"
|
40
|
+
assert_match(/describe Admin::User do/m, contents)
|
41
|
+
end
|
42
|
+
|
25
43
|
def test_model_generator_fixture
|
26
44
|
assert_output(/create test\/fixtures\/users.yml/m) do
|
27
45
|
MiniTest::Generators::ModelGenerator.start ["user"]
|
@@ -29,6 +47,13 @@ class TestModelGenerator < GeneratorTest
|
|
29
47
|
assert File.exists? "test/fixtures/users.yml"
|
30
48
|
end
|
31
49
|
|
50
|
+
def test_namespaced_model_generator_fixture
|
51
|
+
assert_output(/create test\/fixtures\/admin\/users.yml/m) do
|
52
|
+
MiniTest::Generators::ModelGenerator.start ["admin/user"]
|
53
|
+
end
|
54
|
+
assert File.exists? "test/fixtures/admin/users.yml"
|
55
|
+
end
|
56
|
+
|
32
57
|
def test_model_generator_skip_fixture
|
33
58
|
out, _ = capture_io do
|
34
59
|
MiniTest::Generators::ModelGenerator.start ["user", "--skip-fixture"]
|
@@ -36,5 +61,4 @@ class TestModelGenerator < GeneratorTest
|
|
36
61
|
refute_match(/create test\/fixtures\/users.yml/m, out)
|
37
62
|
refute File.exists? "test/fixtures/users.yml"
|
38
63
|
end
|
39
|
-
|
40
64
|
end
|
data/test/helper.rb
CHANGED
@@ -34,3 +34,30 @@ class GeneratorTest < MiniTest::Unit::TestCase
|
|
34
34
|
FakeFS.deactivate!
|
35
35
|
end
|
36
36
|
end
|
37
|
+
|
38
|
+
require "rails/test_help"
|
39
|
+
|
40
|
+
module TestApp
|
41
|
+
class Application < ::Rails::Application
|
42
|
+
config.secret_key_base = "abc123"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
TestApp::Application.initialize!
|
47
|
+
|
48
|
+
class ApplicationController < ActionController::Base; end
|
49
|
+
class ModelsController < ApplicationController
|
50
|
+
def index; render :text => "<html><head><title>Models</title></head><body><h1>All Models</h1></body></html>"; end
|
51
|
+
def new; redirect_to "/models"; end
|
52
|
+
end
|
53
|
+
module Admin
|
54
|
+
class WidgetsController < ApplicationController; end
|
55
|
+
end
|
56
|
+
|
57
|
+
TestApp::Application.routes.draw do
|
58
|
+
# root :to => "models#index"
|
59
|
+
resources :models
|
60
|
+
namespace :admin do
|
61
|
+
resources :widgets
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
class TestActionControllerAssertions < ActionController::TestCase
|
4
|
+
tests ModelsController
|
5
|
+
|
6
|
+
def test_assert_response
|
7
|
+
get :index
|
8
|
+
assert_response :success
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_assert_redirected_to
|
12
|
+
get :new
|
13
|
+
assert_redirected_to :models
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_assert_template
|
17
|
+
get :index
|
18
|
+
assert_template :layout => false
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_routing_assertions
|
22
|
+
params = { :controller => "models", :action => "index" }
|
23
|
+
path = "/models"
|
24
|
+
assert_generates path, params
|
25
|
+
assert_recognizes params, path
|
26
|
+
assert_routing path, params
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_assert_dom_equal
|
30
|
+
apple_link = '<a href="http://www.example.com" target="_blank">Apples</a>'
|
31
|
+
apple_link2 = '<a target="_blank" href="http://www.example.com">Apples</a>'
|
32
|
+
orange_link = '<a href="http://www.example.com">Oranges</a>'
|
33
|
+
|
34
|
+
assert_dom_equal apple_link, apple_link2
|
35
|
+
refute_dom_equal apple_link, orange_link
|
36
|
+
assert_dom_not_equal apple_link, orange_link
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_assert_select
|
40
|
+
get :index
|
41
|
+
assert_select "body h1"
|
42
|
+
assert_select "body" do
|
43
|
+
assert_select "h1"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -1,16 +1,5 @@
|
|
1
1
|
require "helper"
|
2
2
|
|
3
|
-
class TestApp < Rails::Application
|
4
|
-
end
|
5
|
-
Rails.application = TestApp
|
6
|
-
Rails.configuration.secret_key_base = "abc123"
|
7
|
-
|
8
|
-
class ApplicationController < ActionController::Base; end
|
9
|
-
class ModelsController < ApplicationController; end
|
10
|
-
module Admin
|
11
|
-
class WidgetsController < ApplicationController; end
|
12
|
-
end
|
13
|
-
|
14
3
|
# ApplicationController
|
15
4
|
describe ApplicationController do
|
16
5
|
describe "nested" do
|
@@ -136,7 +125,7 @@ end
|
|
136
125
|
# Nested Admin::WidgetsControllerTest
|
137
126
|
module Admin
|
138
127
|
class WidgetsControllerTest < ActionController::TestCase
|
139
|
-
|
128
|
+
def test_exists
|
140
129
|
assert_kind_of Admin::WidgetsController, @controller
|
141
130
|
end
|
142
131
|
end
|
@@ -159,7 +148,7 @@ module Admin
|
|
159
148
|
end
|
160
149
|
|
161
150
|
class Admin::WidgetsControllerTest < ActionController::TestCase
|
162
|
-
|
151
|
+
def test_exists_here_too
|
163
152
|
assert_kind_of Admin::WidgetsController, @controller
|
164
153
|
end
|
165
154
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
class TestActionControllerExpectations < ActionController::TestCase
|
4
|
+
tests ModelsController
|
5
|
+
|
6
|
+
def test_must_respond_with
|
7
|
+
get :index
|
8
|
+
must_respond_with :success
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_must_redirect_to
|
12
|
+
get :new
|
13
|
+
must_redirect_to :models
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_must_render_template
|
17
|
+
get :index
|
18
|
+
must_render_template :layout => false
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_routing_expectations
|
22
|
+
params = { :controller => "models", :action => "index" }
|
23
|
+
path = "/models"
|
24
|
+
params.must_route_to path
|
25
|
+
path.must_route_from params
|
26
|
+
params.must_route_for path
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_must_dom_equal
|
30
|
+
apple_link = '<a href="http://www.example.com" target="_blank">Apples</a>'
|
31
|
+
apple_link2 = '<a target="_blank" href="http://www.example.com">Apples</a>'
|
32
|
+
orange_link = '<a href="http://www.example.com">Oranges</a>'
|
33
|
+
|
34
|
+
apple_link.must_dom_equal apple_link2
|
35
|
+
apple_link.wont_dom_equal orange_link
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_must_select
|
39
|
+
get :index
|
40
|
+
must_select "body h1"
|
41
|
+
must_select "body" do
|
42
|
+
must_select "h1"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|