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 CHANGED
@@ -1,4 +1,9 @@
1
1
 
2
+ ## v4.3.1
3
+
4
+ * Eager load controller_class, mailer_class, and helper_class.
5
+
6
+
2
7
  ## v4.3.0
3
8
 
4
9
  * All new MiniTest::Spec for Rails!!! Tested to the hilt!!!
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
- If you are using minitest-spec-rails with Rails 3.0, then your controller or mailer tests will need to use the `tests` interface for the test to be setup correct within sub `describe` blocks. I think this is a bug with `class_attribute` within Rails 3.0. Rails 3.1 and higher does not exhibit this problem.
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
@@ -3,6 +3,7 @@ end
3
3
 
4
4
  require 'rails'
5
5
  require 'minitest/spec'
6
+ require 'minitest-spec-rails/util'
6
7
  require 'minitest-spec-rails/version'
7
8
  require 'minitest-spec-rails/railtie'
8
9
  require 'test/unit/testcase'
@@ -6,6 +6,8 @@ ActionController::TestCase.instance_eval do
6
6
 
7
7
  register_spec_type(/Controller( ?Test)?\z/i, self)
8
8
 
9
+ before { self.class.controller_class }
10
+
9
11
  end
10
12
 
11
13
  require 'action_dispatch/testing/integration' # For Rails 3.0 loading.
@@ -6,4 +6,6 @@ ActionMailer::TestCase.instance_eval do
6
6
 
7
7
  register_spec_type(/Mailer( ?Test)?\z/i, self)
8
8
 
9
+ before { self.class.mailer_class unless MiniTestSpecRails::Util.rails30? }
10
+
9
11
  end
@@ -16,5 +16,6 @@ ActionView::TestCase.instance_eval do
16
16
  end
17
17
  end
18
18
 
19
+ before { self.class.helper_class }
19
20
 
20
21
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module MiniTestSpecRails
2
- VERSION = "4.3.0"
2
+ VERSION = "4.3.1"
3
3
  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 unless rails30?
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 unless rails30?
35
+ self.class.mailer_class.must_equal user_mailer_class
34
36
  end
35
37
 
36
38
  describe 'nested 2' do
@@ -9,7 +9,7 @@ module UserTests
9
9
  end
10
10
 
11
11
  it 'allows custom assertions' do
12
- assert_blank '' if rails3?
12
+ assert_blank '' if MiniTestSpecRails::Util.rails3?
13
13
  end
14
14
 
15
15
  describe 'nested 1' do
@@ -4,8 +4,9 @@ module UsersControllerTests
4
4
  extend ActiveSupport::Concern
5
5
  included do
6
6
 
7
- it 'works' do
8
- get :index
7
+ before { get :index }
8
+
9
+ it 'works' do
9
10
  assert_select 'h1', "All #{User.count} Users"
10
11
  end
11
12
 
@@ -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.0
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: -1108058497587389129
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: -1108058497587389129
196
+ hash: -825537953231626350
196
197
  requirements: []
197
198
  rubyforge_project:
198
199
  rubygems_version: 1.8.24