minitest-anonymous_controller 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4d881093e02382bdbd17736ce03b64c5828f948d
4
- data.tar.gz: c592ca7342cdcf93822f7ec4d63c7e13ffe4f177
3
+ metadata.gz: 8051af49d53786c3cb4193556ca542cccdb0ce46
4
+ data.tar.gz: e6ac577d4df019196889f1becd706a7f8bbc01d9
5
5
  SHA512:
6
- metadata.gz: 70d9a42f948e58d1aafd3e8447c65f9e16799c330ad6bf20938274f7af0fb82fb4d80b02b7cde9595e41343f6f7b01a30707b985a0b7ce30cf5dcf9908bc0dbe
7
- data.tar.gz: 2af924b5f914a65a52d5ac1e31b2ebf69a0f8a8e2da03f95bad3f34792e037dd85edb80a939d6b9e25681c8bae247f181986bb81e149c2068b22342245b29018
6
+ metadata.gz: a29c7736c64197e1734fe5f659b6921f52111a782c7bc0b58e4515c84c0a604d5cd6e17266d7609cdf1d02362b34a74e08cea790637814f17858be1dce13d04d
7
+ data.tar.gz: db59536bdddc11e4171f039ba4d26ee2a32ba705cda6d3516ec2c08f7c04b877f56125a5226209eabf48dbd18c9363408b06a6f96bfe467b2644fb4c7065217d
data/README.md CHANGED
@@ -12,19 +12,20 @@ gem 'minitest-anonymous_controller'
12
12
 
13
13
  ## Usage
14
14
 
15
- The typical use-cases for anonymous controllers are to test filters defined in a base controller.
15
+ The typical use-cases for anonymous controllers are to test filters defined in a base (sort of abstract) controller.
16
16
 
17
17
  __ApplicationController__
18
18
 
19
19
  ```ruby
20
20
  class ApplicationController < ActionController::Base
21
+ before_action :require_login
21
22
 
22
23
  ...
23
24
 
24
25
  private
25
26
 
26
- def not_authenticated # <= Think if you want to test this filter
27
- redirect_to root_path, alert: 'Please login first'
27
+ def require_login # <= Assume if you want to test this filter
28
+ redirect_to login_url, alert: 'Please login first' unless logged_in?
28
29
  end
29
30
 
30
31
  ...
@@ -32,23 +33,22 @@ class ApplicationController < ActionController::Base
32
33
  end
33
34
  ```
34
35
 
35
- __ApplicatinControllerTest__
36
+ __ApplicationControllerTest__
36
37
 
37
38
  ```ruby
38
39
  require 'test_helper'
39
40
 
40
41
  class ApplicationControllerTest < ActionDispatch::IntegrationTest
41
- extend Minitest::AnonymousController
42
-
43
- ApplicationController.insert_dummy_action
42
+ ApplicationController.insert_dummy_action # <= Insert dummy action to the controller
44
43
 
45
44
  test 'should redirect someone without logging in to login page' do
46
- ApplicationController.stub_any_instance(:current_user, nil) do
47
- get dummy_action_url # <= Now you can test the filter via the dummy action
48
- assert_equal 'Please login first', flash[:alert]
49
- assert_redirected_to login_url
50
- end
45
+ get dummy_action_url # <= Now you can test the filter via the dummy action
46
+ assert_equal 'Please login first', flash[:alert]
47
+ assert_redirected_to root_url
51
48
  end
49
+
50
+ ...
51
+
52
52
  end
53
53
  ```
54
54
 
@@ -6,7 +6,7 @@ module Minitest
6
6
  # Define dummy action for testing in ApplicationController class context
7
7
  self.class_eval do
8
8
  def dummy_action
9
- render :nothing
9
+ head :ok
10
10
  end
11
11
  end
12
12
 
@@ -21,4 +21,4 @@ module Minitest
21
21
  end
22
22
  end
23
23
 
24
- ActionController::Base.extend Minitest::AnonymousController
24
+ ActionController::Base.send(:extend, Minitest::AnonymousController)
@@ -1,5 +1,5 @@
1
1
  module Minitest
2
2
  module AnonymousController
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-anonymous_controller
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hirofumi Wakasugi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-11 00:00:00.000000000 Z
11
+ date: 2016-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler