rails-controller-testing 1.0.1 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1985518a366c6d03e6ee96cc506686ac0c2d965d
4
- data.tar.gz: 97d894de1d866047e6b8fc0d6055b17f91f7d48c
2
+ SHA256:
3
+ metadata.gz: 4d99b6d01bc663c3ba220fff707f26552a28a848317c6f830a31e736ddf1776e
4
+ data.tar.gz: 5d7f585835cdead01990b15b82deef49bcb89f6b717a333ca2111a2df3707262
5
5
  SHA512:
6
- metadata.gz: 54709c6e0bf1f97d9d35e8c613b6f7990a8e11541601b5f16296604d6a3b4e0ee2c86e6a7f4214bcbb54ecc0f5364bec7d670712a45d85694dbe3671062578ac
7
- data.tar.gz: fb983705ffd31ccdc5d93c5b2ebcc478bc08cc2a2bde8d98a8c13068219879f4fbb5716012440de89c7f6323a129cdb2371d1aa37c8f43d3b14d75a776fdc7d4
6
+ metadata.gz: 3a686dc504025f4b3385d996a5e75b87e72e9485b6aac52b4b94ccab73eb5c7a3835dc716499d52d107272670dd213c459e8c4eaa849128b10de0623835d4267
7
+ data.tar.gz: 9a568d4d728af230890f59f4bda89c2ce9d351fc30ebb0118b86f642bbd8ffe3ad7cb1f1f5de68780b91edb3b1cfcbeaf2fa464929500c8df4b8d49d3562ba0d
data/README.md CHANGED
@@ -24,11 +24,11 @@ Or install it yourself as:
24
24
 
25
25
  See https://github.com/rspec/rspec-rails/issues/1393.
26
26
 
27
- rspec-rails will automatically integrate with this gem once `3.5.0` and Rails 5 are released.
27
+ rspec-rails automatically integrates with this gem since version `3.5.0`.
28
28
  Adding the gem to your `Gemfile` is sufficient.
29
29
 
30
- To work around the issue right now, use a beta version of rspec-rails or
31
- manually you'll have to include the modules in your `rails_helper`.
30
+ If you use an older version of rspec-rails, you can manually include the
31
+ modules in your `rails_helper`.
32
32
 
33
33
  ```ruby
34
34
  RSpec.configure do |config|
@@ -1,15 +1,19 @@
1
+ require 'action_pack'
2
+
1
3
  module Rails
2
4
  module Controller
3
5
  module Testing
4
6
  module Integration
5
- %w(
6
- get post patch put head delete xml_http_request
7
- xhr get_via_redirect post_via_redirect
8
- ).each do |method|
7
+ http_verbs = %w(get post patch put head delete)
8
+
9
+ if ActionPack.version < Gem::Version.new('5.1')
10
+ http_verbs.push('xhr', 'xml_http_request', 'get_via_redirect', 'post_via_redirect')
11
+ end
9
12
 
10
- define_method(method) do |*args|
13
+ http_verbs.each do |method|
14
+ define_method(method) do |*args, **kwargs|
11
15
  reset_template_assertion
12
- super(*args)
16
+ super(*args, **kwargs)
13
17
  end
14
18
  end
15
19
  end
@@ -51,12 +51,13 @@ module Rails
51
51
  end
52
52
 
53
53
  def teardown_subscriptions
54
+ return unless defined?(@_subscribers)
54
55
  @_subscribers.each do |subscriber|
55
56
  ActiveSupport::Notifications.unsubscribe(subscriber)
56
57
  end
57
58
  end
58
59
 
59
- def process(*args)
60
+ def process(*, **)
60
61
  reset_template_assertion
61
62
  super
62
63
  end
@@ -1,7 +1,7 @@
1
1
  module Rails
2
2
  module Controller
3
3
  module Testing
4
- VERSION = "1.0.1"
4
+ VERSION = "1.0.5"
5
5
  end
6
6
  end
7
7
  end
@@ -7,17 +7,19 @@ module Rails
7
7
  module Controller
8
8
  module Testing
9
9
  def self.install
10
- ActiveSupport.on_load(:action_controller) do
11
- ActionController::TestCase.include Rails::Controller::Testing::TestProcess
12
- ActionController::TestCase.include Rails::Controller::Testing::TemplateAssertions
10
+ ActiveSupport.on_load(:action_controller_test_case) do
11
+ include Rails::Controller::Testing::TestProcess
12
+ include Rails::Controller::Testing::TemplateAssertions
13
+ end
13
14
 
14
- ActionDispatch::IntegrationTest.include Rails::Controller::Testing::TemplateAssertions
15
- ActionDispatch::IntegrationTest.include Rails::Controller::Testing::Integration
16
- ActionDispatch::IntegrationTest.include Rails::Controller::Testing::TestProcess
15
+ ActiveSupport.on_load(:action_dispatch_integration_test) do
16
+ include Rails::Controller::Testing::TemplateAssertions
17
+ include Rails::Controller::Testing::Integration
18
+ include Rails::Controller::Testing::TestProcess
17
19
  end
18
20
 
19
- ActiveSupport.on_load(:action_view) do
20
- ActionView::TestCase.include Rails::Controller::Testing::TemplateAssertions
21
+ ActiveSupport.on_load(:action_view_test_case) do
22
+ include Rails::Controller::Testing::TemplateAssertions
21
23
  end
22
24
  end
23
25
  end
@@ -19,8 +19,8 @@ class AssignsControllerTest < ActionController::TestCase
19
19
  def test_view_assigns
20
20
  @controller = ViewAssignsController.new
21
21
  process :test_assigns
22
- assert_equal nil, assigns(:foo)
23
- assert_equal nil, assigns[:foo]
22
+ assert_nil assigns(:foo)
23
+ assert_nil assigns[:foo]
24
24
  assert_equal "bar", assigns(:bar)
25
25
  assert_equal "bar", assigns[:bar]
26
26
  end
@@ -12,11 +12,6 @@ class TemplateAssertionsControllerTest < ActionController::TestCase
12
12
  assert_template partial: '_partial'
13
13
  end
14
14
 
15
- def test_file_with_absolute_path_success
16
- get :render_file_absolute_path
17
- assert_template file: File.expand_path('../../dummy/README.rdoc', __FILE__)
18
- end
19
-
20
15
  def test_file_with_relative_path_success
21
16
  get :render_file_relative_path
22
17
  assert_template file: 'README.rdoc'
@@ -28,12 +23,6 @@ class TemplateAssertionsControllerTest < ActionController::TestCase
28
23
  assert_raise(ActiveSupport::TestCase::Assertion) do
29
24
  assert_template :file => 'test/hello_world'
30
25
  end
31
-
32
- get :render_file_absolute_path
33
-
34
- assert_raise(ActiveSupport::TestCase::Assertion) do
35
- assert_template file: nil
36
- end
37
26
  end
38
27
 
39
28
  def test_with_nil_passes_when_no_template_rendered
@@ -20,7 +20,7 @@ class TemplateAssertionsController < ActionController::Base
20
20
  end
21
21
 
22
22
  def render_file_relative_path
23
- render file: 'test/dummy/README.rdoc'
23
+ render file: '/test/dummy/README.rdoc'
24
24
  end
25
25
 
26
26
  def render_with_layout