minitest-spec-rails 3.1.2 → 4.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +9 -6
- data/Appraisals +17 -0
- data/CHANGELOG.md +3 -12
- data/Gemfile +1 -3
- data/README.md +111 -2
- data/Rakefile +8 -0
- data/gemfiles/rails30.gemfile +7 -0
- data/gemfiles/rails30.gemfile.lock +94 -0
- data/gemfiles/rails31.gemfile +7 -0
- data/gemfiles/rails31.gemfile.lock +105 -0
- data/gemfiles/rails32.gemfile +7 -0
- data/gemfiles/rails32.gemfile.lock +104 -0
- data/gemfiles/rails40.gemfile +7 -0
- data/gemfiles/rails40.gemfile.lock +107 -0
- data/lib/minitest-spec-rails.rb +4 -5
- data/lib/minitest-spec-rails/init/action_controller.rb +11 -19
- data/lib/minitest-spec-rails/init/action_mailer.rb +5 -22
- data/lib/minitest-spec-rails/init/action_view.rb +15 -33
- data/lib/minitest-spec-rails/init/active_support.rb +11 -19
- data/lib/minitest-spec-rails/railtie.rb +17 -0
- data/lib/minitest-spec-rails/version.rb +1 -1
- data/lib/test/unit.rb +5 -0
- data/lib/test/unit/assertions.rb +5 -0
- data/lib/test/unit/testcase.rb +31 -0
- data/minitest-spec-rails.gemspec +3 -4
- data/test/cases/action_dispatch_test.rb +2 -2
- data/test/cases/active_support_test.rb +5 -17
- data/test/cases/minitest_spec_rails_test.rb +11 -0
- data/test/dummy_app/app/controllers/users_controller.rb +0 -4
- data/test/dummy_app/app/helpers/application_helper.rb +1 -0
- data/test/dummy_app/app/mailers/user_mailer.rb +10 -0
- data/test/dummy_app/app/models/user.rb +0 -3
- data/test/dummy_app/app/views/users/{index.rhtml → index.html.erb} +0 -0
- data/test/dummy_app/config/database.yml +5 -2
- data/test/dummy_app/config/routes.rb +3 -5
- data/test/dummy_app/init.rb +32 -8
- data/test/dummy_app/{db/schema.rb → tmp/.gitkeep} +0 -0
- data/test/dummy_tests/application_controller_test.rb +23 -67
- data/test/dummy_tests/integration_test.rb +22 -13
- data/test/dummy_tests/user_mailer_test.rb +27 -65
- data/test/dummy_tests/user_test.rb +14 -50
- data/test/dummy_tests/users_controller_test.rb +6 -13
- data/test/dummy_tests/users_helper_test.rb +19 -55
- data/test/support/shared_test_case_behavior.rb +16 -10
- data/test/test_helper.rb +2 -2
- data/test/test_helper_dummy.rb +2 -0
- metadata +33 -75
- data/Guardfile +0 -7
- data/lib/minitest-spec-rails/dsl.rb +0 -52
- data/lib/minitest-spec-rails/init/action_dispatch.rb +0 -17
- data/lib/minitest-spec-rails/init/mini_shoulda.rb +0 -47
- data/lib/minitest-spec-rails/rails.rb +0 -7
- data/test/cases/mini_shoulda_test.rb +0 -38
- data/test/dummy_app/app/helpers/foos_helper.rb +0 -5
- data/test/dummy_app/app/models/post.rb +0 -6
- data/test/dummy_app/app/models/user_mailer.rb +0 -10
- data/test/dummy_app/app/views/user_mailer/welcome.erb +0 -1
- data/test/dummy_app/config/boot.rb +0 -126
- data/test/dummy_app/config/environment.rb +0 -12
- data/test/dummy_app/config/environments/test.rb +0 -28
- data/test/dummy_app/config/initializers/new_rails_defaults.rb +0 -15
- data/test/dummy_app/lib/library.rb +0 -2
- data/test/dummy_app/log/.keep +0 -0
- data/test/dummy_app/public/.htaccess +0 -40
- data/test/dummy_app/public/404.html +0 -30
- data/test/dummy_app/public/422.html +0 -30
- data/test/dummy_app/public/500.html +0 -30
- data/test/dummy_app/script/console +0 -3
- data/test/dummy_app/script/generate +0 -3
- data/test/dummy_tests/foo_helper_test.rb +0 -12
- data/test/dummy_tests/library_test.rb +0 -16
@@ -0,0 +1,107 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git://github.com/rails/rails.git
|
3
|
+
revision: 555cb0afb5a8a8e98fc982edb9e09dfaafd46380
|
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.2.2, < 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/kencollins/Repositories/minitest-spec-rails
|
45
|
+
specs:
|
46
|
+
minitest-spec-rails (4.3.0)
|
47
|
+
minitest (~> 4.3)
|
48
|
+
rails (>= 3.0)
|
49
|
+
|
50
|
+
GEM
|
51
|
+
remote: http://rubygems.org/
|
52
|
+
specs:
|
53
|
+
activerecord-deprecated_finders (0.0.1)
|
54
|
+
appraisal (0.5.1)
|
55
|
+
bundler
|
56
|
+
rake
|
57
|
+
arel (3.0.2)
|
58
|
+
atomic (1.0.1)
|
59
|
+
builder (3.1.4)
|
60
|
+
erubis (2.7.0)
|
61
|
+
hike (1.2.1)
|
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
|
+
minitest-emoji (1.0.0)
|
71
|
+
multi_json (1.5.0)
|
72
|
+
polyglot (0.3.3)
|
73
|
+
rack (1.4.4)
|
74
|
+
rack-test (0.6.2)
|
75
|
+
rack (>= 1.0)
|
76
|
+
rake (10.0.3)
|
77
|
+
rdoc (3.12)
|
78
|
+
json (~> 1.4)
|
79
|
+
sprockets (2.8.2)
|
80
|
+
hike (~> 1.2)
|
81
|
+
multi_json (~> 1.0)
|
82
|
+
rack (~> 1.0)
|
83
|
+
tilt (~> 1.1, != 1.3.0)
|
84
|
+
sprockets-rails (2.0.0.rc1)
|
85
|
+
actionpack (>= 3.0)
|
86
|
+
activesupport (>= 3.0)
|
87
|
+
sprockets (~> 2.8)
|
88
|
+
sqlite3 (1.3.7)
|
89
|
+
thor (0.16.0)
|
90
|
+
thread_safe (0.1.0)
|
91
|
+
atomic
|
92
|
+
tilt (1.3.3)
|
93
|
+
treetop (1.4.12)
|
94
|
+
polyglot
|
95
|
+
polyglot (>= 0.3.1)
|
96
|
+
tzinfo (0.3.35)
|
97
|
+
|
98
|
+
PLATFORMS
|
99
|
+
ruby
|
100
|
+
|
101
|
+
DEPENDENCIES
|
102
|
+
appraisal
|
103
|
+
minitest-emoji
|
104
|
+
minitest-spec-rails!
|
105
|
+
rails!
|
106
|
+
rake
|
107
|
+
sqlite3
|
data/lib/minitest-spec-rails.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
module MiniTestSpecRails
|
2
2
|
end
|
3
3
|
|
4
|
-
require '
|
5
|
-
require 'active_support/all'
|
6
|
-
require 'active_support/test_case'
|
4
|
+
require 'rails'
|
7
5
|
require 'minitest/spec'
|
8
6
|
require 'minitest-spec-rails/version'
|
9
|
-
require 'minitest-spec-rails/
|
10
|
-
require '
|
7
|
+
require 'minitest-spec-rails/railtie'
|
8
|
+
require 'test/unit/testcase'
|
9
|
+
|
@@ -1,24 +1,16 @@
|
|
1
|
-
|
2
|
-
module Init
|
3
|
-
module ActionControllerBehavior
|
1
|
+
ActionController::TestCase.instance_eval do
|
4
2
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
register_spec_type(self) { |desc| Class === desc && desc < self }
|
9
|
-
register_rails_test_case self
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
3
|
+
register_spec_type(self) do |desc|
|
4
|
+
Class === desc && desc < ActionController::Metal
|
5
|
+
end
|
14
6
|
|
15
|
-
|
16
|
-
describing_class.tests described_class
|
17
|
-
super
|
18
|
-
end
|
7
|
+
register_spec_type(/Controller( ?Test)?\z/i, self)
|
19
8
|
|
20
|
-
end
|
21
|
-
end
|
22
9
|
end
|
23
10
|
|
24
|
-
|
11
|
+
require 'action_dispatch/testing/integration' # For Rails 3.0 loading.
|
12
|
+
ActionDispatch::IntegrationTest.instance_eval do
|
13
|
+
|
14
|
+
register_spec_type(/(Acceptance|Integration) ?Test\z/i, self)
|
15
|
+
|
16
|
+
end
|
@@ -1,26 +1,9 @@
|
|
1
|
-
|
2
|
-
module Init
|
3
|
-
module ActionMailerBehavior
|
1
|
+
ActionMailer::TestCase.instance_eval do
|
4
2
|
|
5
|
-
|
6
|
-
|
7
|
-
register_spec_type(self) { |desc| Class === desc && desc < ActionMailer::Base }
|
8
|
-
register_spec_type(/Mailer( ?Test)?\z/i, self)
|
9
|
-
register_spec_type(self) { |desc| Class === desc && desc < self }
|
10
|
-
register_rails_test_case self
|
11
|
-
before { setup_minitest_spec_rails_mailer_class }
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def setup_minitest_spec_rails_mailer_class
|
18
|
-
describing_class.tests described_class
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
3
|
+
register_spec_type(self) do |desc|
|
4
|
+
Class === desc && desc < ActionMailer::Base
|
22
5
|
end
|
23
|
-
end
|
24
6
|
|
25
|
-
|
7
|
+
register_spec_type(/Mailer( ?Test)?\z/i, self)
|
26
8
|
|
9
|
+
end
|
@@ -1,38 +1,20 @@
|
|
1
|
-
|
2
|
-
module Init
|
3
|
-
module ActionViewBehavior
|
1
|
+
ActionView::TestCase.instance_eval do
|
4
2
|
|
5
|
-
|
6
|
-
klass.class_eval do
|
7
|
-
class_attribute :_helper_class
|
8
|
-
register_spec_type(/(Helper|View)( ?Test)?\z/i, self)
|
9
|
-
register_spec_type(self) { |desc| Class === desc && desc < self }
|
10
|
-
register_rails_test_case self
|
11
|
-
before { setup_minitest_spec_rails_helper_class }
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def helper_class=(new_class)
|
18
|
-
self._helper_class = new_class
|
19
|
-
end
|
20
|
-
|
21
|
-
def helper_class
|
22
|
-
if current_helper_class = self._helper_class
|
23
|
-
current_helper_class
|
24
|
-
else
|
25
|
-
self.helper_class = determine_default_helper_class(name)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def setup_minitest_spec_rails_helper_class
|
30
|
-
self.class.helper_class = described_class
|
31
|
-
self.class.send :include_helper_modules!
|
32
|
-
end
|
3
|
+
register_spec_type(/(Helper|View)( ?Test)?\z/i, self)
|
33
4
|
|
5
|
+
# Properly allow the parent class to memoize this for subclasses.
|
6
|
+
# Just like ActionController::TestCase does.
|
7
|
+
class_attribute :_helper_class
|
8
|
+
def helper_class=(new_class)
|
9
|
+
self._helper_class = new_class
|
10
|
+
end
|
11
|
+
def helper_class
|
12
|
+
if current_helper_class = self._helper_class
|
13
|
+
current_helper_class
|
14
|
+
else
|
15
|
+
self.helper_class = determine_default_helper_class(name)
|
34
16
|
end
|
35
17
|
end
|
36
|
-
end
|
37
18
|
|
38
|
-
|
19
|
+
|
20
|
+
end
|
@@ -1,28 +1,20 @@
|
|
1
|
-
|
2
|
-
module Init
|
3
|
-
module ActiveSupportBehavior
|
1
|
+
ActiveSupport::TestCase.instance_eval do
|
4
2
|
|
5
|
-
|
6
|
-
|
7
|
-
extend MiniTest::Spec::DSL
|
8
|
-
include MiniTestSpecRails::DSL
|
9
|
-
register_spec_type(self) { |desc| Class === desc }
|
10
|
-
register_rails_test_case self
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
3
|
+
class << self
|
4
|
+
remove_method :describe
|
15
5
|
end
|
16
|
-
end
|
17
6
|
|
18
|
-
|
7
|
+
register_spec_type(self) do |desc|
|
8
|
+
Class === desc && desc < ActiveRecord::Base
|
9
|
+
end
|
19
10
|
|
11
|
+
end
|
20
12
|
|
21
13
|
# The AbstractController::Helpers#default_helper_module! blows up using
|
22
14
|
# ActiveSupport's modified LoadError class under Ruby 1.8 because describe
|
23
|
-
# blocks with spaces for their names have a `module_path` of something like
|
15
|
+
# blocks with spaces for their names have a `module_path` of something like
|
24
16
|
# "nested 1" while in Ruby 1.9 it is something like "#<Class:0x007fa256ea1118>"
|
25
|
-
# and hence wont find a #path match in REGEXPS due to the space. So add
|
17
|
+
# and hence wont find a #path match in REGEXPS due to the space. So add
|
26
18
|
# another that allows filenames with spaces in it.
|
27
|
-
#
|
28
|
-
|
19
|
+
#
|
20
|
+
LoadError::REGEXPS << %r{^Missing \w+ (?:file\s*)?(.*\.rb)$}i
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module MiniTestSpecRails
|
2
|
+
class Railtie < ::Rails::Railtie
|
3
|
+
|
4
|
+
config.minitest_spec_rails = ActiveSupport::OrderedOptions.new
|
5
|
+
|
6
|
+
config.before_initialize do |app|
|
7
|
+
ActiveSupport.on_load(:action_view) { require 'minitest-spec-rails/init/action_view' }
|
8
|
+
ActiveSupport.on_load(:action_controller) { require 'minitest-spec-rails/init/action_controller' }
|
9
|
+
ActiveSupport.on_load(:action_mailer) { require 'minitest-spec-rails/init/action_mailer' }
|
10
|
+
end
|
11
|
+
|
12
|
+
initializer 'minitest-spec-rails.after.load_active_support', :after => :load_active_support, :group => :all do |app|
|
13
|
+
require 'minitest-spec-rails/init/active_support'
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
data/lib/test/unit.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'minitest-spec-rails'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'pp'
|
4
|
+
|
5
|
+
module Test
|
6
|
+
module Unit
|
7
|
+
|
8
|
+
remove_const(:TestCase) if defined?(self::TestCase)
|
9
|
+
class TestCase < ::MiniTest::Spec
|
10
|
+
|
11
|
+
MINITEST_SPEC_RAILS = true
|
12
|
+
|
13
|
+
def mu_pp(obj)
|
14
|
+
obj.pretty_inspect.chomp
|
15
|
+
end
|
16
|
+
|
17
|
+
def assert_block(*msgs)
|
18
|
+
assert yield, *msgs
|
19
|
+
end
|
20
|
+
|
21
|
+
def build_message(head, template=nil, *arguments)
|
22
|
+
template &&= template.chomp
|
23
|
+
template.gsub(/\G((?:[^\\]|\\.)*?)(\\)?\?/) { $1 + ($2 ? "?" : mu_pp(arguments.shift)) }
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
silence_warnings { MiniTest::Unit::TestCase = MiniTest::Spec }
|
data/minitest-spec-rails.gemspec
CHANGED
@@ -15,11 +15,10 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
16
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
17
|
gem.require_paths = ['lib']
|
18
|
-
gem.add_runtime_dependency 'minitest', '~> 4.
|
19
|
-
gem.add_runtime_dependency 'rails',
|
20
|
-
gem.add_development_dependency '
|
18
|
+
gem.add_runtime_dependency 'minitest', '~> 4.3'
|
19
|
+
gem.add_runtime_dependency 'rails', '>= 3.0'
|
20
|
+
gem.add_development_dependency 'appraisal'
|
21
21
|
gem.add_development_dependency 'minitest-emoji'
|
22
|
-
gem.add_development_dependency 'minitest-focus'
|
23
22
|
gem.add_development_dependency 'rake'
|
24
23
|
gem.add_development_dependency 'sqlite3'
|
25
24
|
end
|
@@ -38,11 +38,11 @@ class ActionControllerTest < MiniTestSpecRails::TestCase
|
|
38
38
|
private
|
39
39
|
|
40
40
|
def assert_dispatch(actual)
|
41
|
-
assert_equal
|
41
|
+
assert_equal ActionDispatch::IntegrationTest, actual
|
42
42
|
end
|
43
43
|
|
44
44
|
def refute_dispatch(actual)
|
45
|
-
refute_equal
|
45
|
+
refute_equal ActionDispatch::IntegrationTest, actual
|
46
46
|
end
|
47
47
|
|
48
48
|
end
|
@@ -4,6 +4,10 @@ class SomeRandomModel < ActiveRecord::Base; end
|
|
4
4
|
|
5
5
|
class ActiveSupportTest < MiniTestSpecRails::TestCase
|
6
6
|
|
7
|
+
it 'removes ActiveSupport describe method' do
|
8
|
+
ActiveSupport::TestCase.singleton_methods(false).map(&:to_sym).wont_include :describe
|
9
|
+
end
|
10
|
+
|
7
11
|
it 'resolves spect type for active record constants' do
|
8
12
|
assert_support MiniTest::Spec.spec_type(SomeRandomModel)
|
9
13
|
assert_support MiniTest::Spec.spec_type(User)
|
@@ -13,6 +17,7 @@ class ActiveSupportTest < MiniTestSpecRails::TestCase
|
|
13
17
|
assert_spec MiniTest::Spec.spec_type("Unmatched String")
|
14
18
|
end
|
15
19
|
|
20
|
+
|
16
21
|
private
|
17
22
|
|
18
23
|
def assert_support(actual)
|
@@ -24,20 +29,3 @@ class ActiveSupportTest < MiniTestSpecRails::TestCase
|
|
24
29
|
end
|
25
30
|
|
26
31
|
end
|
27
|
-
|
28
|
-
class ActiveSupportCallbackTest < ActiveSupport::TestCase
|
29
|
-
|
30
|
-
setup :foo
|
31
|
-
setup :bar
|
32
|
-
|
33
|
-
it 'works' do
|
34
|
-
@foo.must_equal 'foo'
|
35
|
-
@bar.must_equal 'bar'
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def foo ; @foo = 'foo' ; end
|
41
|
-
def bar ; @bar = 'bar' ; end
|
42
|
-
|
43
|
-
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class MiniTestSpecRailsTest < MiniTestSpecRails::TestCase
|
4
|
+
|
5
|
+
it 'defines MINITEST_SPEC_RAILS in the Test::Unit::TestCase shim' do
|
6
|
+
assert Test::Unit::TestCase.const_defined? :MINITEST_SPEC_RAILS
|
7
|
+
assert Test::Unit::TestCase::MINITEST_SPEC_RAILS
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
end
|