minitest-rails 0.3 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,56 +1,53 @@
|
|
1
1
|
require "active_support/concern"
|
2
|
+
require "active_support/inflector"
|
2
3
|
|
3
4
|
module MiniTest
|
4
5
|
module Rails
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
extend ::ActiveSupport::Concern
|
6
|
+
module Testing
|
7
|
+
# Resolves a constant from a minitest spec name.
|
8
|
+
#
|
9
|
+
# Given the following spec-style test:
|
10
|
+
#
|
11
|
+
# describe WidgetsController, :index do
|
12
|
+
# describe "authenticated user" do
|
13
|
+
# describe "returns widgets" do
|
14
|
+
# it "has a controller that exists" do
|
15
|
+
# assert_kind_of WidgetsController, @controller
|
16
|
+
# end
|
17
|
+
# end
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
# The test will have the following name:
|
22
|
+
#
|
23
|
+
# "WidgetsController::index::authenticated user::returns widgets"
|
24
|
+
#
|
25
|
+
# The constant WidgetsController can be resolved from the name.
|
26
|
+
# The following code will resolve the constant:
|
27
|
+
#
|
28
|
+
# controller = determine_constant_from_test_name(name) do |constant|
|
29
|
+
# Class === constant && constant < ::ActionController::Metal
|
30
|
+
# end
|
31
|
+
module ConstantLookup
|
32
|
+
extend ::ActiveSupport::Concern
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
ensure
|
47
|
-
names.pop
|
48
|
-
end
|
34
|
+
module ClassMethods # :nodoc:
|
35
|
+
def determine_constant_from_test_name(test_name)
|
36
|
+
names = test_name.split "::"
|
37
|
+
while names.size > 0 do
|
38
|
+
names.last.sub!(/Test$/, "")
|
39
|
+
begin
|
40
|
+
constant = names.join("::").constantize
|
41
|
+
break(constant) if yield(constant)
|
42
|
+
rescue NameError
|
43
|
+
# Constant wasn't found, move on
|
44
|
+
ensure
|
45
|
+
names.pop
|
49
46
|
end
|
50
47
|
end
|
51
48
|
end
|
52
|
-
|
53
49
|
end
|
50
|
+
|
54
51
|
end
|
55
52
|
end
|
56
53
|
end
|
@@ -1,81 +1,52 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
|
4
|
-
# The default tests to run, update this list to change behavior
|
5
|
-
MINITEST_TASKS = %w(models helpers controllers mailers acceptance) #views
|
6
|
-
|
7
|
-
def all_directories_under_test
|
8
|
-
Dir['test/*/'].map {|dir| /test\/(.+?)\//.match(dir)[1] }
|
9
|
-
end
|
10
|
-
|
11
|
-
def all_minitest_directories
|
12
|
-
(MINITEST_TASKS + all_directories_under_test).uniq
|
13
|
-
end
|
1
|
+
require "rake/testtask"
|
2
|
+
require "minitest/rails/testing"
|
3
|
+
require "minitest/rails/tasks/sub_test_task"
|
14
4
|
|
15
5
|
desc "Runs minitest"
|
16
6
|
task :test do
|
17
7
|
# Add to existing task if exists, or create new task otherwise
|
18
|
-
Rake::Task[
|
8
|
+
Rake::Task["minitest"].invoke
|
19
9
|
end
|
20
10
|
|
21
|
-
namespace
|
11
|
+
namespace "test" do
|
22
12
|
task :prepare do
|
23
13
|
# Define here in case test_unit isn't loaded
|
24
14
|
end
|
25
15
|
end
|
26
16
|
|
27
|
-
desc "Runs #{
|
17
|
+
# desc "Runs default tests (#{MiniTest::Rails::Testing.default_tasks.join(', ')})"
|
28
18
|
task :minitest do
|
29
|
-
Rake::Task[
|
19
|
+
Rake::Task["minitest:default"].invoke
|
30
20
|
end
|
31
21
|
|
32
|
-
namespace
|
22
|
+
namespace "minitest" do
|
33
23
|
|
34
|
-
# Only run the default tasks defined in
|
24
|
+
# Only run the default tasks defined in MiniTest::Rails::Testing.default_tasks
|
35
25
|
task :default do
|
36
|
-
|
37
|
-
begin
|
38
|
-
Rake::Task["minitest:#{task}"].invoke
|
39
|
-
nil
|
40
|
-
rescue => e
|
41
|
-
{ :task => "minitest:#{task}", :exception => e }
|
42
|
-
end
|
43
|
-
end.compact
|
44
|
-
|
45
|
-
if errors.any?
|
46
|
-
puts errors.map { |e| "Errors running #{e[:task]}! #{e[:exception].inspect}" }.join("\n")
|
47
|
-
abort
|
48
|
-
end
|
26
|
+
MiniTest::Rails::Testing.run_tests MiniTest::Rails::Testing.default_tasks
|
49
27
|
end
|
50
28
|
|
51
29
|
# Run all tests in all the test directories
|
30
|
+
# desc "Runs all tests"
|
52
31
|
task :all do
|
53
|
-
|
54
|
-
begin
|
55
|
-
Rake::Task["minitest:#{task}"].invoke
|
56
|
-
nil
|
57
|
-
rescue => e
|
58
|
-
{ :task => "minitest:#{task}", :exception => e }
|
59
|
-
end
|
60
|
-
end.compact
|
61
|
-
|
62
|
-
if errors.any?
|
63
|
-
puts errors.map { |e| "Errors running #{e[:task]}! #{e[:exception].inspect}" }.join("\n")
|
64
|
-
abort
|
65
|
-
end
|
32
|
+
MiniTest::Rails::Testing.run_tests MiniTest::Rails::Testing.all_tasks
|
66
33
|
end
|
67
34
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
35
|
+
MiniTest::Rails::Testing.all_tasks.each do |task_dir|
|
36
|
+
unless Rake::Task.task_defined? "minitest:#{task_dir}"
|
37
|
+
# desc "Runs tests under test/#{task_dir}"
|
38
|
+
MiniTest::Rails::Tasks::SubTestTask.new(task_dir => "test:prepare") do |t|
|
39
|
+
t.libs.push "test"
|
40
|
+
t.pattern = "test/#{task_dir}/**/*_test.rb"
|
41
|
+
t.options = MiniTest::Rails::Testing.task_opts[task_dir] if MiniTest::Rails::Testing.task_opts[task_dir]
|
42
|
+
end
|
72
43
|
end
|
73
44
|
end
|
74
45
|
|
75
46
|
end
|
76
47
|
|
77
48
|
# Override the default task
|
78
|
-
task :default => [] # Just in case it hasn
|
49
|
+
task :default => [] # Just in case it hasn"t already been set
|
79
50
|
Rake::Task[:default].clear
|
80
|
-
desc "Runs
|
51
|
+
desc "Runs default tests"
|
81
52
|
task :default => "minitest"
|
@@ -0,0 +1,93 @@
|
|
1
|
+
gem "minitest" # make sure we get the gem, not stdlib
|
2
|
+
require "minitest/spec"
|
3
|
+
|
4
|
+
# I hate this! Be sure you have installed minitest_tu_shim
|
5
|
+
require "test/unit" if RUBY_VERSION < "1.9"
|
6
|
+
|
7
|
+
begin
|
8
|
+
require "active_support/testing/tagged_logging"
|
9
|
+
rescue LoadError; end
|
10
|
+
require "active_support/testing/setup_and_teardown"
|
11
|
+
require "active_support/testing/assertions"
|
12
|
+
require "active_support/testing/deprecation"
|
13
|
+
require "active_support/testing/pending"
|
14
|
+
require "active_support/testing/isolation"
|
15
|
+
require "active_support/core_ext/kernel/reporting"
|
16
|
+
|
17
|
+
begin
|
18
|
+
require 'active_support/testing/constant_lookup'
|
19
|
+
rescue LoadError; end
|
20
|
+
require "minitest/rails/constant_lookup"
|
21
|
+
|
22
|
+
begin
|
23
|
+
silence_warnings { require "mocha/setup" }
|
24
|
+
rescue LoadError
|
25
|
+
end
|
26
|
+
|
27
|
+
module MiniTest
|
28
|
+
module Rails
|
29
|
+
class TestCase < MiniTest::Spec
|
30
|
+
|
31
|
+
# This is deprecated in minitest, but I don't want to change the Rails calls to it.
|
32
|
+
# Keep it here for now, until a better way presents itself...
|
33
|
+
def assert_block msg = nil
|
34
|
+
msg = message(msg) { "Expected block to return true value" }
|
35
|
+
assert yield, msg
|
36
|
+
end
|
37
|
+
|
38
|
+
# For backward compatibility with Test::Unit
|
39
|
+
def build_message(message, template = nil, *args)
|
40
|
+
template = template.gsub('<?>', '<%s>')
|
41
|
+
message || sprintf(template, *args)
|
42
|
+
end
|
43
|
+
|
44
|
+
Assertion = MiniTest::Assertion
|
45
|
+
alias_method :method_name, :name if method_defined? :name
|
46
|
+
alias_method :method_name, :__name__ if method_defined? :__name__
|
47
|
+
|
48
|
+
$tags = {}
|
49
|
+
def self.for_tag(tag)
|
50
|
+
yield if $tags[tag]
|
51
|
+
end
|
52
|
+
|
53
|
+
include ::ActiveSupport::Testing::TaggedLogging if defined? ActiveSupport::Testing::TaggedLogging
|
54
|
+
include ::ActiveSupport::Testing::SetupAndTeardown
|
55
|
+
include ::ActiveSupport::Testing::Assertions
|
56
|
+
include ::ActiveSupport::Testing::Deprecation
|
57
|
+
include ::ActiveSupport::Testing::Pending
|
58
|
+
|
59
|
+
# Alias `it` instead of extending ActiveSupport::Testing::Declarative
|
60
|
+
class << self
|
61
|
+
alias :test :it
|
62
|
+
end
|
63
|
+
|
64
|
+
# Resolve constants from the test name when using the spec DSL
|
65
|
+
include Testing::ConstantLookup
|
66
|
+
|
67
|
+
# test/unit backwards compatibility methods
|
68
|
+
alias :assert_raise :assert_raises
|
69
|
+
alias :assert_not_empty :refute_empty
|
70
|
+
alias :assert_not_equal :refute_equal
|
71
|
+
alias :assert_not_in_delta :refute_in_delta
|
72
|
+
alias :assert_not_in_epsilon :refute_in_epsilon
|
73
|
+
alias :assert_not_includes :refute_includes
|
74
|
+
alias :assert_not_instance_of :refute_instance_of
|
75
|
+
alias :assert_not_kind_of :refute_kind_of
|
76
|
+
alias :assert_no_match :refute_match
|
77
|
+
alias :assert_not_nil :refute_nil
|
78
|
+
alias :assert_not_operator :refute_operator
|
79
|
+
alias :assert_not_predicate :refute_predicate
|
80
|
+
alias :assert_not_respond_to :refute_respond_to
|
81
|
+
alias :assert_not_same :refute_same
|
82
|
+
|
83
|
+
# Fails if the block raises an exception.
|
84
|
+
#
|
85
|
+
# assert_nothing_raised do
|
86
|
+
# ...
|
87
|
+
# end
|
88
|
+
def assert_nothing_raised(*args)
|
89
|
+
yield
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "rake/testtask"
|
2
|
+
|
3
|
+
module MiniTest
|
4
|
+
module Rails
|
5
|
+
module Testing
|
6
|
+
mattr_accessor :default_tasks
|
7
|
+
mattr_accessor :task_opts
|
8
|
+
|
9
|
+
self.default_tasks = %w(models helpers controllers mailers integration)
|
10
|
+
self.task_opts = { "performance" => "-- --benchmark" }
|
11
|
+
|
12
|
+
def self.all_tasks
|
13
|
+
Dir["test/*/"].map {|dir| /test\/(.+?)\//.match(dir)[1] }.select do |dir|
|
14
|
+
!Dir.glob("test/#{dir}/**/*_test.rb").empty?
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
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
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/minitest-rails.gemspec
CHANGED
@@ -2,21 +2,21 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "minitest-rails"
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.5.20130110235401"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Mike Moore"]
|
9
|
-
s.date = "
|
10
|
-
s.description = "Adds MiniTest as the default testing library in Rails 3
|
9
|
+
s.date = "2013-01-11"
|
10
|
+
s.description = "Adds MiniTest as the default testing library in Rails 3 and 4"
|
11
11
|
s.email = ["mike@blowmage.com"]
|
12
12
|
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.0.gemfile.lock", "gemfiles/3.1.gemfile", "gemfiles/3.1.gemfile.lock", "gemfiles/3.2.gemfile", "gemfiles/3.2.gemfile.lock", "gemfiles/
|
13
|
+
s.files = [".autotest", ".gemtest", ".travis.yml", "CHANGELOG.rdoc", "LICENSE", "Manifest.txt", "README.rdoc", "Rakefile", "gemfiles/3.0.gemfile", "gemfiles/3.0.gemfile.lock", "gemfiles/3.1.gemfile", "gemfiles/3.1.gemfile.lock", "gemfiles/3.2.gemfile", "gemfiles/3.2.gemfile.lock", "gemfiles/4.0.gemfile", "gemfiles/4.0.gemfile.lock", "lib/autotest/discover.rb", "lib/autotest/fixtures.rb", "lib/autotest/migrate.rb", "lib/autotest/minitest_rails.rb", "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/minitest_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/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/constant_lookup.rb", "lib/minitest/rails/tasks/minitest.rake", "lib/minitest/rails/tasks/sub_test_task.rb", "lib/minitest/rails/test_case.rb", "lib/minitest/rails/testing.rb", "lib/minitest/rails/version.rb", "minitest-rails.gemspec", "tasks/gemfiles.rake", "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_scaffold_generator.rb", "test/helper.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"]
|
14
14
|
s.homepage = "http://blowmage.com/minitest-rails"
|
15
15
|
s.rdoc_options = ["--main", "README.rdoc"]
|
16
16
|
s.require_paths = ["lib"]
|
17
17
|
s.rubyforge_project = "minitest-rails"
|
18
18
|
s.rubygems_version = "1.8.23"
|
19
|
-
s.summary = "MiniTest integration for Rails 3
|
19
|
+
s.summary = "MiniTest integration for Rails 3 and 4"
|
20
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_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"]
|
21
21
|
|
22
22
|
if s.respond_to? :specification_version then
|
@@ -24,22 +24,22 @@ Gem::Specification.new do |s|
|
|
24
24
|
|
25
25
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
26
26
|
s.add_runtime_dependency(%q<minitest>, ["~> 4.0"])
|
27
|
-
s.add_runtime_dependency(%q<rails>, ["
|
27
|
+
s.add_runtime_dependency(%q<rails>, [">= 3.0"])
|
28
28
|
s.add_development_dependency(%q<rdoc>, ["~> 3.10"])
|
29
29
|
s.add_development_dependency(%q<fakefs>, ["~> 0.4"])
|
30
|
-
s.add_development_dependency(%q<hoe>, ["~> 3.
|
30
|
+
s.add_development_dependency(%q<hoe>, ["~> 3.4"])
|
31
31
|
else
|
32
32
|
s.add_dependency(%q<minitest>, ["~> 4.0"])
|
33
|
-
s.add_dependency(%q<rails>, ["
|
33
|
+
s.add_dependency(%q<rails>, [">= 3.0"])
|
34
34
|
s.add_dependency(%q<rdoc>, ["~> 3.10"])
|
35
35
|
s.add_dependency(%q<fakefs>, ["~> 0.4"])
|
36
|
-
s.add_dependency(%q<hoe>, ["~> 3.
|
36
|
+
s.add_dependency(%q<hoe>, ["~> 3.4"])
|
37
37
|
end
|
38
38
|
else
|
39
39
|
s.add_dependency(%q<minitest>, ["~> 4.0"])
|
40
|
-
s.add_dependency(%q<rails>, ["
|
40
|
+
s.add_dependency(%q<rails>, [">= 3.0"])
|
41
41
|
s.add_dependency(%q<rdoc>, ["~> 3.10"])
|
42
42
|
s.add_dependency(%q<fakefs>, ["~> 0.4"])
|
43
|
-
s.add_dependency(%q<hoe>, ["~> 3.
|
43
|
+
s.add_dependency(%q<hoe>, ["~> 3.4"])
|
44
44
|
end
|
45
45
|
end
|
data/tasks/gemfiles.rake
CHANGED
@@ -4,10 +4,11 @@ namespace :gemfiles do
|
|
4
4
|
`bundle --gemfile=gemfiles/3.0.gemfile`
|
5
5
|
`bundle --gemfile=gemfiles/3.1.gemfile`
|
6
6
|
`bundle --gemfile=gemfiles/3.2.gemfile`
|
7
|
+
`bundle --gemfile=gemfiles/4.0.gemfile`
|
7
8
|
end
|
8
9
|
desc "Clear the gemfile lock files"
|
9
10
|
task :clear do
|
10
|
-
`rm gemfiles
|
11
|
+
`rm gemfiles/*.gemfile.lock`
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
data/tasks/test.rake
CHANGED
@@ -16,5 +16,11 @@ namespace :test do
|
|
16
16
|
ENV["BUNDLE_GEMFILE"] = "gemfiles/3.2.gemfile"
|
17
17
|
sh "bundle exec rake test"
|
18
18
|
end
|
19
|
+
|
20
|
+
desc "Run tests against the 4.0 gemfile"
|
21
|
+
task "4.0" do
|
22
|
+
ENV["BUNDLE_GEMFILE"] = "gemfiles/4.0.gemfile"
|
23
|
+
sh "bundle exec rake test"
|
24
|
+
end
|
19
25
|
end
|
20
26
|
|
@@ -1,71 +1,42 @@
|
|
1
|
-
require "
|
2
|
-
require "minitest-rails"
|
3
|
-
|
4
|
-
require "rails"
|
5
|
-
require "rails/generators"
|
6
|
-
|
1
|
+
require "helper"
|
7
2
|
require "generators/mini_test/controller/controller_generator"
|
8
3
|
|
9
|
-
|
10
|
-
|
11
|
-
class FakeFS::File
|
12
|
-
def self.binread file
|
13
|
-
File.open(file, "rb") { |f| f.read }
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
class TestControllerGenerator < MiniTest::Unit::TestCase
|
18
|
-
def setup
|
19
|
-
Rails::Generators.no_color!
|
20
|
-
FakeFS.activate!
|
21
|
-
FakeFS::FileSystem.clone "lib/generators"
|
22
|
-
end
|
23
|
-
|
24
|
-
def teardown
|
25
|
-
FakeFS::FileSystem.clear
|
26
|
-
FakeFS.deactivate!
|
27
|
-
end
|
4
|
+
class TestControllerGenerator < GeneratorTest
|
28
5
|
|
29
6
|
def test_controller_generator
|
30
|
-
|
7
|
+
assert_output(/create test\/controllers\/user_controller_test.rb/m) do
|
31
8
|
MiniTest::Generators::ControllerGenerator.start ["user"]
|
32
9
|
end
|
33
|
-
assert_match(/create test\/controllers\/user_controller_test.rb/m, out)
|
34
10
|
assert File.exists? "test/controllers/user_controller_test.rb"
|
35
11
|
contents = File.read "test/controllers/user_controller_test.rb"
|
36
12
|
assert_match(/class UserControllerTest/m, contents)
|
37
13
|
end
|
38
14
|
|
39
15
|
def test_namespaced_controller_generator
|
40
|
-
|
16
|
+
assert_output(/create test\/controllers\/admin\/user_controller_test.rb/m) do
|
41
17
|
MiniTest::Generators::ControllerGenerator.start ["admin/user"]
|
42
18
|
end
|
43
|
-
assert_match(/create test\/controllers\/admin\/user_controller_test.rb/m, out)
|
44
19
|
assert File.exists? "test/controllers/admin/user_controller_test.rb"
|
45
20
|
contents = File.read "test/controllers/admin/user_controller_test.rb"
|
46
21
|
assert_match(/class Admin::UserControllerTest/m, contents)
|
47
22
|
end
|
48
23
|
|
49
24
|
def test_controller_generator_spec
|
50
|
-
|
25
|
+
assert_output(/create test\/controllers\/user_controller_test.rb/m) do
|
51
26
|
MiniTest::Generators::ControllerGenerator.start ["user", "--spec"]
|
52
27
|
end
|
53
|
-
assert_match(/create test\/controllers\/user_controller_test.rb/m, out)
|
54
28
|
assert File.exists? "test/controllers/user_controller_test.rb"
|
55
29
|
contents = File.read "test/controllers/user_controller_test.rb"
|
56
30
|
assert_match(/describe UserController do/m, contents)
|
57
31
|
end
|
58
32
|
|
59
33
|
def test_namespaced_controller_generator_spec
|
60
|
-
|
61
|
-
|
62
|
-
MiniTest::Generators::ControllerGenerator.start ["admin/user", "--spec"]
|
63
|
-
end
|
64
|
-
assert_match(/create test\/controllers\/admin\/user_controller_test.rb/m, out)
|
65
|
-
assert File.exists? "test/controllers/admin/user_controller_test.rb"
|
66
|
-
contents = File.read "test/controllers/admin/user_controller_test.rb"
|
67
|
-
assert_match(/describe Admin::UserController do/m, contents)
|
34
|
+
assert_output(/create test\/controllers\/admin\/user_controller_test.rb/m) do
|
35
|
+
MiniTest::Generators::ControllerGenerator.start ["admin/user", "--spec"]
|
68
36
|
end
|
37
|
+
assert File.exists? "test/controllers/admin/user_controller_test.rb"
|
38
|
+
contents = File.read "test/controllers/admin/user_controller_test.rb"
|
39
|
+
assert_match(/describe Admin::UserController do/m, contents)
|
69
40
|
end
|
70
41
|
|
71
42
|
end
|