minitest-rails 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +4 -6
- data/lib/generators/mini_test/controller/templates/controller_spec.rb +7 -1
- data/lib/generators/mini_test/helper/templates/helper_spec.rb +2 -4
- data/lib/generators/mini_test/install/templates/test/minitest_helper.rb +47 -4
- data/lib/generators/mini_test/mailer/templates/mailer_spec.rb +3 -2
- data/lib/generators/mini_test/model/templates/fixtures.yml +2 -1
- data/lib/generators/mini_test/model/templates/model_spec.rb +8 -2
- data/lib/generators/mini_test/scaffold/templates/controller_spec.rb +8 -2
- data/lib/generators/mini_test/scaffold/templates/controller_test.rb +1 -1
- data/lib/minitest-rails.rb +2 -1
- data/lib/minitest/rails.rb +1 -0
- data/lib/minitest/rails/controller.rb +7 -2
- data/lib/minitest/rails/spec.rb +3 -0
- data/test/test_controller_generator.rb +4 -1
- data/test/test_helper_generator.rb +1 -1
- data/test/test_install_generator.rb +9 -0
- data/test/test_mailer_generator.rb +3 -2
- data/test/test_model_generator.rb +3 -1
- data/test/test_scaffold_generator.rb +2 -1
- metadata +22 -33
data/Rakefile
CHANGED
@@ -9,18 +9,16 @@ Hoe.plugins.delete :rubyforge
|
|
9
9
|
Hoe.spec 'minitest-rails' do
|
10
10
|
developer 'Mike Moore', 'mike@blowmage.com'
|
11
11
|
|
12
|
-
self.summary = 'MiniTest integration for Rails 3.
|
13
|
-
self.description = 'Adds MiniTest as the default testing library in Rails.'
|
12
|
+
self.summary = 'MiniTest integration for Rails 3.'
|
13
|
+
self.description = 'Adds MiniTest as the default testing library in Rails 3.'
|
14
14
|
self.url = 'http://blowmage.com/minitest-rails'
|
15
15
|
|
16
16
|
self.history_file = "CHANGELOG.rdoc"
|
17
17
|
self.readme_file = "README.rdoc"
|
18
18
|
self.testlib = :minitest
|
19
19
|
|
20
|
-
extra_deps << ['minitest',
|
21
|
-
extra_deps << ['
|
22
|
-
extra_deps << ['activesupport', '~> 3.1.0.rc1']
|
23
|
-
extra_deps << ['actionpack', '~> 3.1.0.rc1']
|
20
|
+
extra_deps << ['minitest', '~> 2.11']
|
21
|
+
extra_deps << ['rails', '~> 3.1']
|
24
22
|
end
|
25
23
|
|
26
24
|
# vim: syntax=ruby
|
@@ -1,6 +1,11 @@
|
|
1
1
|
require "minitest_helper"
|
2
2
|
|
3
|
-
|
3
|
+
describe <%= class_name %>Controller do
|
4
|
+
|
5
|
+
subject { <%= class_name %>Controller }
|
6
|
+
|
7
|
+
# fixtures :all
|
8
|
+
|
4
9
|
before do
|
5
10
|
@controller = <%= class_name %>Controller.new
|
6
11
|
end
|
@@ -8,4 +13,5 @@ class <%= class_name %>ControllerTest < MiniTest::Rails::Controller
|
|
8
13
|
it "must be a real test" do
|
9
14
|
flunk "Need real tests"
|
10
15
|
end
|
16
|
+
|
11
17
|
end
|
@@ -1,11 +1,9 @@
|
|
1
1
|
require "minitest_helper"
|
2
2
|
|
3
|
-
|
4
|
-
before do
|
5
|
-
@helper= <%= class_name %>Helper.new
|
6
|
-
end
|
3
|
+
describe <%= class_name %>Helper do
|
7
4
|
|
8
5
|
it "must be a real test" do
|
9
6
|
flunk "Need real tests"
|
10
7
|
end
|
8
|
+
|
11
9
|
end
|
@@ -1,18 +1,61 @@
|
|
1
1
|
require "minitest/autorun"
|
2
2
|
require "minitest/rails"
|
3
3
|
|
4
|
+
# Uncomment if you want awesome colorful output
|
5
|
+
# require "minitest/pride"
|
6
|
+
|
4
7
|
ENV["RAILS_ENV"] = "test"
|
5
8
|
require File.expand_path('../../config/environment', __FILE__)
|
6
9
|
|
7
10
|
class MiniTest::Rails::Spec
|
11
|
+
# Uncomment if you want to support fixtures for all specs
|
12
|
+
# or
|
13
|
+
# place within spec class you want to support fixtures for
|
14
|
+
# include MiniTest::Rails::Fixtures
|
8
15
|
|
9
16
|
# Add methods to be used by all specs here...
|
10
17
|
|
11
18
|
end
|
12
19
|
|
13
|
-
# Uncomment to support fixtures in Model tests...
|
14
|
-
# require "active_record/fixtures"
|
15
20
|
class MiniTest::Rails::Model
|
16
|
-
|
17
|
-
#
|
21
|
+
|
22
|
+
# Add methods to be used by model specs here...
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
MiniTest::Spec.register_spec_type(MiniTest::Rails::Model) do |desc|
|
27
|
+
desc.superclass == ActiveRecord::Base
|
28
|
+
end
|
29
|
+
|
30
|
+
class MiniTest::Rails::Controller
|
31
|
+
include ActionController::TestCase::Behavior
|
32
|
+
before do
|
33
|
+
@request = ActionController::TestRequest.new
|
34
|
+
@response = ActionController::TestResponse.new
|
35
|
+
@routes = Rails.application.routes
|
36
|
+
end
|
37
|
+
|
38
|
+
# Add methods to be used by controller specs here...
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
MiniTest::Spec.register_spec_type(/Controller$/, MiniTest::Rails::Controller)
|
43
|
+
|
44
|
+
class MiniTest::Rails::Helper
|
45
|
+
|
46
|
+
# Add methods to be used by helper specs here...
|
47
|
+
|
18
48
|
end
|
49
|
+
|
50
|
+
MiniTest::Spec.register_spec_type(/Helper$/, MiniTest::Rails::Helper)
|
51
|
+
|
52
|
+
class MiniTest::Rails::Mailer
|
53
|
+
|
54
|
+
# Add methods to be used by mailer specs here...
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
MiniTest::Spec.register_spec_type(MiniTest::Rails::Mailer) do |desc|
|
59
|
+
desc.superclass == ActionMailer::Base
|
60
|
+
end
|
61
|
+
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require "minitest_helper"
|
2
2
|
|
3
|
-
|
3
|
+
describe <%= class_name %> do
|
4
|
+
|
4
5
|
<% actions.each do |action| -%>
|
5
6
|
it "<%= action %>" do
|
6
7
|
mail = <%= class_name %>.<%= action %>
|
@@ -9,11 +10,11 @@ class <%= class_name %>Test < MiniTest::Rails::Mailer
|
|
9
10
|
mail.from.must_equal ["from@example.com"]
|
10
11
|
mail.body.encoded.must_match "Hi"
|
11
12
|
end
|
12
|
-
|
13
13
|
<% end -%>
|
14
14
|
<% if actions.blank? -%>
|
15
15
|
it "must be a real test" do
|
16
16
|
flunk "Need real tests"
|
17
17
|
end
|
18
18
|
<% end -%>
|
19
|
+
|
19
20
|
end
|
@@ -1,6 +1,11 @@
|
|
1
1
|
require "minitest_helper"
|
2
2
|
|
3
|
-
|
3
|
+
describe <%= class_name %> do
|
4
|
+
|
5
|
+
subject { <%= class_name %>.new }
|
6
|
+
|
7
|
+
# fixtures :all
|
8
|
+
|
4
9
|
before do
|
5
10
|
@<%= file_name %> = <%= class_name %>.new
|
6
11
|
end
|
@@ -19,4 +24,5 @@ class <%= class_name %>Test < MiniTest::Rails::Model
|
|
19
24
|
# @<%= file_name %>.interesting?.must_equal true
|
20
25
|
# end
|
21
26
|
# end
|
22
|
-
|
27
|
+
|
28
|
+
end
|
@@ -1,8 +1,13 @@
|
|
1
1
|
require "minitest_helper"
|
2
2
|
|
3
3
|
<% module_namespacing do -%>
|
4
|
-
|
5
|
-
|
4
|
+
describe <%= class_name %>Controller do
|
5
|
+
|
6
|
+
subject { <%= class_name %>Controller }
|
7
|
+
|
8
|
+
# fixtures :all
|
9
|
+
|
10
|
+
before do
|
6
11
|
@<%= singular_table_name %> = <%= table_name %>(:one)
|
7
12
|
end
|
8
13
|
|
@@ -47,5 +52,6 @@ class <%= class_name %>ControllerTest < MiniTest::Rails::Controller
|
|
47
52
|
|
48
53
|
assert_redirected_to <%= index_helper %>_path
|
49
54
|
end
|
55
|
+
|
50
56
|
end
|
51
57
|
<% end -%>
|
data/lib/minitest-rails.rb
CHANGED
data/lib/minitest/rails.rb
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
require "minitest/rails/spec"
|
2
|
-
|
2
|
+
require "active_support/test_case"
|
3
|
+
require "action_controller/test_case"
|
3
4
|
|
4
5
|
module MiniTest
|
5
6
|
module Rails
|
6
7
|
class Controller < Spec
|
7
|
-
|
8
|
+
include ActiveSupport::Testing::SetupAndTeardown
|
9
|
+
include ActionController::TestCase::Behavior
|
10
|
+
before do
|
11
|
+
@routes = Rails.application.routes
|
12
|
+
end
|
8
13
|
end
|
9
14
|
end
|
10
15
|
end
|
data/lib/minitest/rails/spec.rb
CHANGED
@@ -33,7 +33,10 @@ class TestControllerGenerator < MiniTest::Unit::TestCase
|
|
33
33
|
assert_match(/create test\/controllers\/user_controller_test.rb/m, text)
|
34
34
|
assert File.exists? "test/controllers/user_controller_test.rb"
|
35
35
|
contents = open("test/controllers/user_controller_test.rb").read
|
36
|
-
assert_match(/
|
36
|
+
assert_match(/describe UserController do/m, contents)
|
37
|
+
assert_match(/subject \{ UserController \}/m, contents)
|
38
|
+
assert_match(/# fixtures :all/m, contents)
|
39
|
+
assert_match(/@controller = UserController.new/m, contents)
|
37
40
|
assert_match(/it "must be a real test"/m, contents)
|
38
41
|
ensure
|
39
42
|
FileUtils.rm_r "test/controllers"
|
@@ -32,7 +32,7 @@ class TestHelperGenerator < MiniTest::Unit::TestCase
|
|
32
32
|
assert_match(/create test\/helpers\/user_helper_test.rb/m, text)
|
33
33
|
assert File.exists? "test/helpers/user_helper_test.rb"
|
34
34
|
contents = open("test/helpers/user_helper_test.rb").read
|
35
|
-
assert_match(/
|
35
|
+
assert_match(/describe UserHelper do/m, contents)
|
36
36
|
ensure
|
37
37
|
FileUtils.rm_r "test/helpers"
|
38
38
|
end
|
@@ -19,6 +19,15 @@ class TestInstallGenerator < MiniTest::Unit::TestCase
|
|
19
19
|
assert File.exists? "test/minitest_helper.rb"
|
20
20
|
contents = open("test/minitest_helper.rb").read
|
21
21
|
assert_match(/class MiniTest::Rails::Spec/m, contents)
|
22
|
+
assert_match(/# include MiniTest::Rails::Fixtures/m, contents)
|
23
|
+
assert_match(/class MiniTest::Rails::Model/m, contents)
|
24
|
+
assert_match(/MiniTest::Spec.register_spec_type\(MiniTest::Rails::Model\) do/m, contents)
|
25
|
+
assert_match(/class MiniTest::Rails::Controller/m, contents)
|
26
|
+
assert_match(/MiniTest::Spec.register_spec_type\(\/Controller\$\/, MiniTest::Rails::Controller\)/m, contents)
|
27
|
+
assert_match(/class MiniTest::Rails::Helper/m, contents)
|
28
|
+
assert_match(/MiniTest::Spec.register_spec_type\(\/Helper\$\/, MiniTest::Rails::Helper\)/m, contents)
|
29
|
+
assert_match(/class MiniTest::Rails::Mailer/m, contents)
|
30
|
+
assert_match(/MiniTest::Spec.register_spec_type\(MiniTest::Rails::Mailer\) do/m, contents)
|
22
31
|
ensure
|
23
32
|
# TODO: Don"t write the files
|
24
33
|
# I agree, it would be better to mock the file getting written
|
@@ -27,12 +27,13 @@ class TestMailerGenerator < MiniTest::Unit::TestCase
|
|
27
27
|
|
28
28
|
def test_mailer_generator_spec
|
29
29
|
text = capture(:stdout) do
|
30
|
-
MiniTest::Generators::MailerGenerator.start ["notification", "--spec"]
|
30
|
+
MiniTest::Generators::MailerGenerator.start ["notification", "welcome", "--spec"]
|
31
31
|
end
|
32
32
|
assert_match(/create test\/mailers\/notification_test.rb/m, text)
|
33
33
|
assert File.exists? "test/mailers/notification_test.rb"
|
34
34
|
contents = open("test/mailers/notification_test.rb").read
|
35
|
-
assert_match(/
|
35
|
+
assert_match(/describe Notification do/m, contents)
|
36
|
+
assert_match(/it "welcome" do/m, contents)
|
36
37
|
ensure
|
37
38
|
FileUtils.rm_r "test/mailers"
|
38
39
|
end
|
@@ -32,7 +32,9 @@ class TestModelGenerator < MiniTest::Unit::TestCase
|
|
32
32
|
assert_match(/create test\/models\/user_test.rb/m, text)
|
33
33
|
assert File.exists? "test/models/user_test.rb"
|
34
34
|
contents = open("test/models/user_test.rb").read
|
35
|
-
assert_match(/
|
35
|
+
assert_match(/describe User do/m, contents)
|
36
|
+
assert_match(/subject \{ User.new \}/, contents)
|
37
|
+
assert_match(/# fixtures :all/, contents)
|
36
38
|
ensure
|
37
39
|
FileUtils.rm_r "test/models"
|
38
40
|
end
|
@@ -33,7 +33,8 @@ class TestScaffoldGenerator < MiniTest::Unit::TestCase
|
|
33
33
|
assert_match(/create test\/controllers\/user_controller_test.rb/m, text)
|
34
34
|
assert File.exists? "test/controllers/user_controller_test.rb"
|
35
35
|
contents = open("test/controllers/user_controller_test.rb").read
|
36
|
-
assert_match(/
|
36
|
+
assert_match(/describe UserController do/m, contents)
|
37
|
+
assert_match(/subject \{ UserController \}/m, contents)
|
37
38
|
assert_match(/it "must get index"/m, contents)
|
38
39
|
ensure
|
39
40
|
FileUtils.rm_r "test/controllers"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,71 +9,61 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
default_executable:
|
12
|
+
date: 2012-03-14 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: minitest
|
17
|
-
requirement: &
|
16
|
+
requirement: &70095363735960 !ruby/object:Gem::Requirement
|
18
17
|
none: false
|
19
18
|
requirements:
|
20
19
|
- - ~>
|
21
20
|
- !ruby/object:Gem::Version
|
22
|
-
version: '2.
|
21
|
+
version: '2.11'
|
23
22
|
type: :runtime
|
24
23
|
prerelease: false
|
25
|
-
version_requirements: *
|
24
|
+
version_requirements: *70095363735960
|
26
25
|
- !ruby/object:Gem::Dependency
|
27
|
-
name:
|
28
|
-
requirement: &
|
26
|
+
name: rails
|
27
|
+
requirement: &70095363735520 !ruby/object:Gem::Requirement
|
29
28
|
none: false
|
30
29
|
requirements:
|
31
30
|
- - ~>
|
32
31
|
- !ruby/object:Gem::Version
|
33
|
-
version: 3.1
|
32
|
+
version: '3.1'
|
34
33
|
type: :runtime
|
35
34
|
prerelease: false
|
36
|
-
version_requirements: *
|
35
|
+
version_requirements: *70095363735520
|
37
36
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
39
|
-
requirement: &
|
37
|
+
name: rdoc
|
38
|
+
requirement: &70095363735080 !ruby/object:Gem::Requirement
|
40
39
|
none: false
|
41
40
|
requirements:
|
42
41
|
- - ~>
|
43
42
|
- !ruby/object:Gem::Version
|
44
|
-
version: 3.
|
45
|
-
type: :
|
46
|
-
prerelease: false
|
47
|
-
version_requirements: *2156678320
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: actionpack
|
50
|
-
requirement: &2156677900 !ruby/object:Gem::Requirement
|
51
|
-
none: false
|
52
|
-
requirements:
|
53
|
-
- - ~>
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: 3.1.0.rc1
|
56
|
-
type: :runtime
|
43
|
+
version: '3.10'
|
44
|
+
type: :development
|
57
45
|
prerelease: false
|
58
|
-
version_requirements: *
|
46
|
+
version_requirements: *70095363735080
|
59
47
|
- !ruby/object:Gem::Dependency
|
60
48
|
name: hoe
|
61
|
-
requirement: &
|
49
|
+
requirement: &70095363734640 !ruby/object:Gem::Requirement
|
62
50
|
none: false
|
63
51
|
requirements:
|
64
52
|
- - ~>
|
65
53
|
- !ruby/object:Gem::Version
|
66
|
-
version: 2.
|
54
|
+
version: '2.16'
|
67
55
|
type: :development
|
68
56
|
prerelease: false
|
69
|
-
version_requirements: *
|
70
|
-
description: Adds MiniTest as the default testing library in Rails.
|
57
|
+
version_requirements: *70095363734640
|
58
|
+
description: Adds MiniTest as the default testing library in Rails 3.
|
71
59
|
email:
|
72
60
|
- mike@blowmage.com
|
73
61
|
executables: []
|
74
62
|
extensions: []
|
75
63
|
extra_rdoc_files:
|
64
|
+
- CHANGELOG.rdoc
|
76
65
|
- Manifest.txt
|
66
|
+
- README.rdoc
|
77
67
|
files:
|
78
68
|
- .autotest
|
79
69
|
- CHANGELOG.rdoc
|
@@ -115,7 +105,6 @@ files:
|
|
115
105
|
- test/test_model_generator.rb
|
116
106
|
- test/test_scaffold_generator.rb
|
117
107
|
- .gemtest
|
118
|
-
has_rdoc: true
|
119
108
|
homepage: http://blowmage.com/minitest-rails
|
120
109
|
licenses: []
|
121
110
|
post_install_message:
|
@@ -138,10 +127,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
127
|
version: '0'
|
139
128
|
requirements: []
|
140
129
|
rubyforge_project: minitest-rails
|
141
|
-
rubygems_version: 1.
|
130
|
+
rubygems_version: 1.8.16
|
142
131
|
signing_key:
|
143
132
|
specification_version: 3
|
144
|
-
summary: MiniTest integration for Rails 3.
|
133
|
+
summary: MiniTest integration for Rails 3.
|
145
134
|
test_files:
|
146
135
|
- test/test_controller_generator.rb
|
147
136
|
- test/test_helper_generator.rb
|