minitest-rails 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -2
- data/CHANGELOG.rdoc +7 -0
- data/Manifest.txt +7 -1
- data/README.rdoc +20 -3
- data/Rakefile +3 -2
- data/gemfiles/3.0.gemfile +1 -0
- data/gemfiles/3.0.gemfile.lock +92 -0
- data/gemfiles/3.1.gemfile +1 -0
- data/gemfiles/3.1.gemfile.lock +103 -0
- data/gemfiles/3.2.gemfile +1 -0
- data/gemfiles/3.2.gemfile.lock +101 -0
- data/gemfiles/minitest_tu_shim.rb +4 -0
- data/lib/generators/mini_test.rb +11 -3
- data/lib/minitest-rails.rb +1 -1
- data/lib/minitest/rails/action_controller.rb +41 -0
- data/lib/minitest/rails/active_support.rb +4 -0
- data/minitest-rails.gemspec +7 -4
- data/test/generators/test_controller_generator.rb +34 -27
- data/test/generators/test_helper_generator.rb +29 -24
- data/test/generators/test_install_generator.rb +20 -9
- data/test/generators/test_mailer_generator.rb +23 -14
- data/test/generators/test_model_generator.rb +27 -25
- data/test/generators/test_scaffold_generator.rb +23 -14
- data/test/rails/action_controller/test_controller_lookup.rb +49 -0
- data/test/rails/action_controller/test_controllers.rb +223 -0
- data/test/rails/{test_action_controller_spec_type.rb → action_controller/test_spec_type.rb} +0 -0
- metadata +28 -4
@@ -6,34 +6,43 @@ require "rails/generators"
|
|
6
6
|
|
7
7
|
require "generators/mini_test/scaffold/scaffold_generator"
|
8
8
|
|
9
|
-
require "
|
9
|
+
require "fakefs/safe"
|
10
|
+
|
11
|
+
class FakeFS::File
|
12
|
+
def self.binread file
|
13
|
+
File.open(file, "rb") { |f| f.read }
|
14
|
+
end
|
15
|
+
end
|
10
16
|
|
11
17
|
class TestScaffoldGenerator < MiniTest::Unit::TestCase
|
12
|
-
|
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
|
13
28
|
|
14
29
|
def test_scaffold_generator
|
15
|
-
|
30
|
+
out, err = capture_io do
|
16
31
|
MiniTest::Generators::ScaffoldGenerator.start ["user"]
|
17
32
|
end
|
18
|
-
assert_match(/create test\/controllers\/users_controller_test.rb/m,
|
33
|
+
assert_match(/create test\/controllers\/users_controller_test.rb/m, out)
|
19
34
|
assert File.exists? "test/controllers/users_controller_test.rb"
|
20
|
-
contents =
|
35
|
+
contents = File.read "test/controllers/users_controller_test.rb"
|
21
36
|
assert_match(/class UsersControllerTest/m, contents)
|
22
|
-
ensure
|
23
|
-
# TODO: Don"t write the files
|
24
|
-
# I agree, it would be better to mock the file getting written
|
25
|
-
FileUtils.rm_r "test/controllers"
|
26
37
|
end
|
27
38
|
|
28
39
|
def test_scaffold_generator_spec
|
29
|
-
|
40
|
+
out, err = capture_io do
|
30
41
|
MiniTest::Generators::ScaffoldGenerator.start ["user", "--spec"]
|
31
42
|
end
|
32
|
-
assert_match(/create test\/controllers\/users_controller_test.rb/m,
|
43
|
+
assert_match(/create test\/controllers\/users_controller_test.rb/m, out)
|
33
44
|
assert File.exists? "test/controllers/users_controller_test.rb"
|
34
|
-
contents =
|
45
|
+
contents = File.read "test/controllers/users_controller_test.rb"
|
35
46
|
assert_match(/describe UsersController do/m, contents)
|
36
|
-
ensure
|
37
|
-
FileUtils.rm_r "test/controllers"
|
38
47
|
end
|
39
48
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "rails"
|
3
|
+
|
4
|
+
require "minitest/rails/action_controller"
|
5
|
+
require "action_controller"
|
6
|
+
|
7
|
+
class ApplicationController < ActionController::Base; end
|
8
|
+
class ModelsController < ApplicationController; end
|
9
|
+
module Admin
|
10
|
+
class WidgetsController < ApplicationController; end
|
11
|
+
end
|
12
|
+
|
13
|
+
class TestControllerLookup < MiniTest::Unit::TestCase
|
14
|
+
include MiniTest::Rails::ActionController
|
15
|
+
def test_find_application_controller
|
16
|
+
assert_equal ApplicationController, ControllerLookup.find("ApplicationController")
|
17
|
+
assert_equal ApplicationController, ControllerLookup.find("ApplicationControllerTest")
|
18
|
+
assert_equal ApplicationController, ControllerLookup.find("ApplicationController::index")
|
19
|
+
assert_equal ApplicationController, ControllerLookup.find("ApplicationController::index::authenticated")
|
20
|
+
assert_equal ApplicationController, ControllerLookup.find("ApplicationControllerTest::index")
|
21
|
+
assert_equal ApplicationController, ControllerLookup.find("ApplicationControllerTest::index::authenticated")
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_find_models_controller
|
25
|
+
assert_equal ModelsController, ControllerLookup.find("ModelsController")
|
26
|
+
assert_equal ModelsController, ControllerLookup.find("ModelsControllerTest")
|
27
|
+
assert_equal ModelsController, ControllerLookup.find("ModelsController::index")
|
28
|
+
assert_equal ModelsController, ControllerLookup.find("ModelsController::index::authenticated")
|
29
|
+
assert_equal ModelsController, ControllerLookup.find("ModelsControllerTest::index")
|
30
|
+
assert_equal ModelsController, ControllerLookup.find("ModelsControllerTest::index::authenticated")
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_find_admin_widgets_controller
|
34
|
+
assert_equal Admin::WidgetsController, ControllerLookup.find("Admin::WidgetsController")
|
35
|
+
assert_equal Admin::WidgetsController, ControllerLookup.find("Admin::WidgetsControllerTest")
|
36
|
+
assert_equal Admin::WidgetsController, ControllerLookup.find("Admin::WidgetsController::index")
|
37
|
+
assert_equal Admin::WidgetsController, ControllerLookup.find("Admin::WidgetsController::index::authenticated")
|
38
|
+
assert_equal Admin::WidgetsController, ControllerLookup.find("Admin::WidgetsControllerTest::index")
|
39
|
+
assert_equal Admin::WidgetsController, ControllerLookup.find("Admin::WidgetsControllerTest::index::authenticated")
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_raises_when_cant_find_controller
|
43
|
+
assert_raises(NameError) { ControllerLookup.find("DoesntExistController") }
|
44
|
+
assert_raises(NameError) { ControllerLookup.find("DoesntExistControllerTest") }
|
45
|
+
assert_raises(NameError) { ControllerLookup.find("DoesntExistController::Nadda") }
|
46
|
+
assert_raises(NameError) { ControllerLookup.find("DoesntExistController::Nadda::Nope") }
|
47
|
+
assert_raises(NameError) { ControllerLookup.find("DoesntExistController::Nadda::Nope::NotHere") }
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,223 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "rails"
|
3
|
+
|
4
|
+
require "minitest/rails/action_controller"
|
5
|
+
require "action_controller"
|
6
|
+
|
7
|
+
# require "active_record/railtie"
|
8
|
+
require "action_controller/railtie"
|
9
|
+
# require "action_mailer/railtie"
|
10
|
+
# require "active_resource/railtie"
|
11
|
+
# require "sprockets/railtie"
|
12
|
+
# require "rails/test_unit/railtie"
|
13
|
+
|
14
|
+
class TestApp < Rails::Application
|
15
|
+
end
|
16
|
+
Rails.application = TestApp
|
17
|
+
|
18
|
+
class ApplicationController < ActionController::Base; end
|
19
|
+
class ModelsController < ApplicationController; end
|
20
|
+
module Admin
|
21
|
+
class WidgetsController < ApplicationController; end
|
22
|
+
end
|
23
|
+
|
24
|
+
# ApplicationController
|
25
|
+
describe ApplicationController do
|
26
|
+
describe "nested" do
|
27
|
+
describe "even deeper" do
|
28
|
+
it "exists" do
|
29
|
+
assert_kind_of ApplicationController, @controller
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe ApplicationController, :index do
|
36
|
+
describe "nested" do
|
37
|
+
describe "even deeper" do
|
38
|
+
it "exists" do
|
39
|
+
assert_kind_of ApplicationController, @controller
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe ApplicationController, "unauthenticated user" do
|
46
|
+
describe "nested" do
|
47
|
+
describe "even deeper" do
|
48
|
+
it "exists" do
|
49
|
+
assert_kind_of ApplicationController, @controller
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "ApplicationControllerTest" do
|
56
|
+
describe "nested" do
|
57
|
+
describe "even deeper" do
|
58
|
+
it "exists" do
|
59
|
+
assert_kind_of ApplicationController, @controller
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "ApplicationControllerTest", :index do
|
66
|
+
describe "nested" do
|
67
|
+
describe "even deeper" do
|
68
|
+
it "exists" do
|
69
|
+
assert_kind_of ApplicationController, @controller
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "ApplicationControllerTest", "unauthenticated user" do
|
76
|
+
describe "nested" do
|
77
|
+
describe "even deeper" do
|
78
|
+
it "exists" do
|
79
|
+
assert_kind_of ApplicationController, @controller
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# ModelsController
|
86
|
+
describe ModelsController do
|
87
|
+
describe "nested" do
|
88
|
+
describe "even deeper" do
|
89
|
+
it "exists" do
|
90
|
+
assert_kind_of ModelsController, @controller
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe ModelsController, :index do
|
97
|
+
describe "nested" do
|
98
|
+
describe "even deeper" do
|
99
|
+
it "exists" do
|
100
|
+
assert_kind_of ModelsController, @controller
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe ModelsController, "unauthenticated user" do
|
107
|
+
describe "nested" do
|
108
|
+
describe "even deeper" do
|
109
|
+
it "exists" do
|
110
|
+
assert_kind_of ModelsController, @controller
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe "ModelsControllerTest" do
|
117
|
+
describe "nested" do
|
118
|
+
describe "even deeper" do
|
119
|
+
it "exists" do
|
120
|
+
assert_kind_of ModelsController, @controller
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
describe "ModelsControllerTest", :index do
|
127
|
+
describe "nested" do
|
128
|
+
describe "even deeper" do
|
129
|
+
it "exists" do
|
130
|
+
assert_kind_of ModelsController, @controller
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
describe "ModelsControllerTest", "unauthenticated user" do
|
137
|
+
describe "nested" do
|
138
|
+
describe "even deeper" do
|
139
|
+
it "exists" do
|
140
|
+
assert_kind_of ModelsController, @controller
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
# Nested Admin::WidgetsControllerTest
|
147
|
+
module Admin
|
148
|
+
class WidgetsControllerTest < MiniTest::Rails::ActionController::TestCase
|
149
|
+
test "exists" do
|
150
|
+
assert_kind_of Admin::WidgetsController, @controller
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
describe WidgetsController do
|
155
|
+
describe "index" do
|
156
|
+
it "respond successful" do
|
157
|
+
assert_kind_of Admin::WidgetsController, @controller
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
describe WidgetsController, "unauthenticated users" do
|
163
|
+
describe "index" do
|
164
|
+
it "respond successful" do
|
165
|
+
assert_kind_of Admin::WidgetsController, @controller
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
class Admin::WidgetsControllerTest < MiniTest::Rails::ActionController::TestCase
|
172
|
+
test "exists here too" do
|
173
|
+
assert_kind_of Admin::WidgetsController, @controller
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
describe Admin::WidgetsController do
|
178
|
+
describe "index" do
|
179
|
+
it "respond successful" do
|
180
|
+
assert_kind_of Admin::WidgetsController, @controller
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
describe Admin::WidgetsController, "unauthenticated users" do
|
186
|
+
describe "index" do
|
187
|
+
it "respond successful" do
|
188
|
+
assert_kind_of Admin::WidgetsController, @controller
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
describe "Admin::WidgetsController" do
|
194
|
+
describe "index" do
|
195
|
+
it "respond successful" do
|
196
|
+
assert_kind_of Admin::WidgetsController, @controller
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
describe "Admin::WidgetsControllerTest" do
|
202
|
+
describe "index" do
|
203
|
+
it "respond successful" do
|
204
|
+
assert_kind_of Admin::WidgetsController, @controller
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
describe "Admin::WidgetsController", "unauthenticated users" do
|
210
|
+
describe "index" do
|
211
|
+
it "respond successful" do
|
212
|
+
assert_kind_of Admin::WidgetsController, @controller
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
describe "Admin::WidgetsControllerTest", "unauthenticated users" do
|
218
|
+
describe "index" do
|
219
|
+
it "respond successful" do
|
220
|
+
assert_kind_of Admin::WidgetsController, @controller
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
File without changes
|
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.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
@@ -59,6 +59,22 @@ dependencies:
|
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '3.10'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: fakefs
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.4'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0.4'
|
62
78
|
- !ruby/object:Gem::Dependency
|
63
79
|
name: hoe
|
64
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,8 +110,12 @@ files:
|
|
94
110
|
- README.rdoc
|
95
111
|
- Rakefile
|
96
112
|
- gemfiles/3.0.gemfile
|
113
|
+
- gemfiles/3.0.gemfile.lock
|
97
114
|
- gemfiles/3.1.gemfile
|
115
|
+
- gemfiles/3.1.gemfile.lock
|
98
116
|
- gemfiles/3.2.gemfile
|
117
|
+
- gemfiles/3.2.gemfile.lock
|
118
|
+
- gemfiles/minitest_tu_shim.rb
|
99
119
|
- lib/generators/mini_test.rb
|
100
120
|
- lib/generators/mini_test/controller/controller_generator.rb
|
101
121
|
- lib/generators/mini_test/controller/templates/controller_spec.rb
|
@@ -136,7 +156,9 @@ files:
|
|
136
156
|
- test/generators/test_mailer_generator.rb
|
137
157
|
- test/generators/test_model_generator.rb
|
138
158
|
- test/generators/test_scaffold_generator.rb
|
139
|
-
- test/rails/
|
159
|
+
- test/rails/action_controller/test_controller_lookup.rb
|
160
|
+
- test/rails/action_controller/test_controllers.rb
|
161
|
+
- test/rails/action_controller/test_spec_type.rb
|
140
162
|
- test/rails/test_action_dispatch_spec_type.rb
|
141
163
|
- test/rails/test_action_mailer_spec_type.rb
|
142
164
|
- test/rails/test_action_view_spec_type.rb
|
@@ -174,7 +196,9 @@ test_files:
|
|
174
196
|
- test/generators/test_mailer_generator.rb
|
175
197
|
- test/generators/test_model_generator.rb
|
176
198
|
- test/generators/test_scaffold_generator.rb
|
177
|
-
- test/rails/
|
199
|
+
- test/rails/action_controller/test_controller_lookup.rb
|
200
|
+
- test/rails/action_controller/test_controllers.rb
|
201
|
+
- test/rails/action_controller/test_spec_type.rb
|
178
202
|
- test/rails/test_action_dispatch_spec_type.rb
|
179
203
|
- test/rails/test_action_mailer_spec_type.rb
|
180
204
|
- test/rails/test_action_view_spec_type.rb
|