minitest-spec-rails 4.3.0 → 4.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -0
- data/README.md +23 -2
- data/lib/minitest-spec-rails.rb +1 -0
- data/lib/minitest-spec-rails/init/action_controller.rb +2 -0
- data/lib/minitest-spec-rails/init/action_mailer.rb +2 -0
- data/lib/minitest-spec-rails/init/action_view.rb +1 -0
- data/lib/minitest-spec-rails/util.rb +13 -0
- data/lib/minitest-spec-rails/version.rb +1 -1
- data/test/dummy_tests/application_controller_test.rb +5 -1
- data/test/dummy_tests/user_mailer_test.rb +3 -1
- data/test/dummy_tests/user_test.rb +1 -1
- data/test/dummy_tests/users_controller_test.rb +3 -2
- data/test/support/shared_test_case_behavior.rb +0 -10
- metadata +4 -3
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -84,17 +84,38 @@ end
|
|
84
84
|
describe UsersHelper do
|
85
85
|
end
|
86
86
|
```
|
87
|
-
|
88
87
|
|
89
88
|
|
90
89
|
## Gotchas
|
91
90
|
|
91
|
+
### Assertion Methods
|
92
|
+
|
92
93
|
If you are upgrading from Test::Unit, there are a few missing assertions that have been renamed or are no longer available within MiniTest.
|
93
94
|
|
94
95
|
* The method `assert_raise` is renamed `assert_raises`.
|
95
96
|
* There is no method `assert_nothing_raised`. There are good reasons for this on [Ryan's blog entry](http://blog.zenspider.com/blog/2012/01/assert_nothing_tested.html).
|
96
97
|
|
97
|
-
|
98
|
+
### Mocha
|
99
|
+
|
100
|
+
If you are using [Mocha](https://github.com/freerange/mocha) for mocking and stubbing, please update to the latest, 0.13.1 or higher so it is compatible with the latest MiniTest. If you do not like the deprecation warnings in older versions of Rails, just add this below the `require 'rails/all'` within your `application.rb` file :)
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
require 'mocha/deprecation'
|
104
|
+
Mocha::Deprecation.mode = :disabled
|
105
|
+
```
|
106
|
+
|
107
|
+
### Rails 3.0.x
|
108
|
+
|
109
|
+
If you are using minitest-spec-rails with Rails 3.0, then your controller and mailer tests will need to use the `tests` interface for the assertions to be setup correctly within sub `describe` blocks. I think this is a bug with `class_attribute` within Rails 3.0 only. So use the following patterns.
|
110
|
+
|
111
|
+
```ruby
|
112
|
+
class UsersControllerTest < ActionController::TestCase
|
113
|
+
tests UsersController
|
114
|
+
end
|
115
|
+
class UserMailerTest < ActionMailer::TestCase
|
116
|
+
tests UserMailer
|
117
|
+
end
|
118
|
+
```
|
98
119
|
|
99
120
|
|
100
121
|
## Contributing
|
data/lib/minitest-spec-rails.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
module MiniTestSpecRails
|
2
|
+
module Util
|
3
|
+
|
4
|
+
def self.rails3? ; rails30? || rails31? || rails32? ; end
|
5
|
+
def self.rails30? ; rails_version == '3.0' ; end
|
6
|
+
def self.rails31? ; rails_version == '3.1' ; end
|
7
|
+
def self.rails32? ; rails_version == '3.2' ; end
|
8
|
+
def self.rails40? ; rails_version == '4.0' ; end
|
9
|
+
|
10
|
+
def self.rails_version ; ::Rails.version.split('.')[0,2].join('.') ; end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
@@ -4,6 +4,10 @@ module ApplicationControllerTests
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
included do
|
6
6
|
|
7
|
+
tests ApplicationController if MiniTestSpecRails::Util.rails30?
|
8
|
+
|
9
|
+
before { get :index }
|
10
|
+
|
7
11
|
it 'works' do
|
8
12
|
get :index
|
9
13
|
response.body.must_equal 'Rendered MiniTest::Spec'
|
@@ -26,7 +30,7 @@ module ApplicationControllerTests
|
|
26
30
|
it('works') { skip }
|
27
31
|
|
28
32
|
it 'can find the controller_class' do
|
29
|
-
self.class.controller_class.must_equal ApplicationController
|
33
|
+
self.class.controller_class.must_equal ApplicationController
|
30
34
|
end
|
31
35
|
|
32
36
|
describe 'nested 2' do
|
@@ -4,6 +4,8 @@ module UserMailerTests
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
included do
|
6
6
|
|
7
|
+
tests UserMailer if MiniTestSpecRails::Util.rails30?
|
8
|
+
|
7
9
|
let(:deliveries) { ActionMailer::Base.deliveries }
|
8
10
|
let(:user_mailer_class) { UserMailer }
|
9
11
|
let(:user_email) { user_mailer_class.welcome(user_ken).deliver }
|
@@ -30,7 +32,7 @@ module UserMailerTests
|
|
30
32
|
it('works') { skip }
|
31
33
|
|
32
34
|
it 'can find the mailer_class' do
|
33
|
-
self.class.mailer_class.must_equal user_mailer_class
|
35
|
+
self.class.mailer_class.must_equal user_mailer_class
|
34
36
|
end
|
35
37
|
|
36
38
|
describe 'nested 2' do
|
@@ -20,16 +20,6 @@ module MiniTestSpecRails
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
24
|
-
def rails_version
|
25
|
-
Rails.version.split('.')[0,2].join('.')
|
26
|
-
end
|
27
|
-
|
28
|
-
def rails3? ; rails30? || rails31? || rails32? ; end
|
29
|
-
def rails30? ; rails_version == '3.0' ; end
|
30
|
-
def rails31? ; rails_version == '3.1' ; end
|
31
|
-
def rails32? ; rails_version == '3.2' ; end
|
32
|
-
def rails40? ; rails_version == '4.0' ; end
|
33
23
|
|
34
24
|
end
|
35
25
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-spec-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.3.
|
4
|
+
version: 4.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -137,6 +137,7 @@ files:
|
|
137
137
|
- lib/minitest-spec-rails/init/action_view.rb
|
138
138
|
- lib/minitest-spec-rails/init/active_support.rb
|
139
139
|
- lib/minitest-spec-rails/railtie.rb
|
140
|
+
- lib/minitest-spec-rails/util.rb
|
140
141
|
- lib/minitest-spec-rails/version.rb
|
141
142
|
- lib/test/unit.rb
|
142
143
|
- lib/test/unit/assertions.rb
|
@@ -183,7 +184,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
183
184
|
version: '0'
|
184
185
|
segments:
|
185
186
|
- 0
|
186
|
-
hash: -
|
187
|
+
hash: -825537953231626350
|
187
188
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
189
|
none: false
|
189
190
|
requirements:
|
@@ -192,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
193
|
version: '0'
|
193
194
|
segments:
|
194
195
|
- 0
|
195
|
-
hash: -
|
196
|
+
hash: -825537953231626350
|
196
197
|
requirements: []
|
197
198
|
rubyforge_project:
|
198
199
|
rubygems_version: 1.8.24
|