rails-controller-testing 1.0.1 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +3 -3
- data/lib/rails/controller/testing/integration.rb +10 -6
- data/lib/rails/controller/testing/template_assertions.rb +2 -1
- data/lib/rails/controller/testing/version.rb +1 -1
- data/lib/rails/controller/testing.rb +10 -8
- data/test/controllers/assigns_test.rb +2 -2
- data/test/controllers/template_assertions_test.rb +0 -11
- data/test/dummy/app/controllers/template_assertions_controller.rb +1 -1
- data/test/dummy/log/test.log +9791 -0
- metadata +53 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4d99b6d01bc663c3ba220fff707f26552a28a848317c6f830a31e736ddf1776e
|
4
|
+
data.tar.gz: 5d7f585835cdead01990b15b82deef49bcb89f6b717a333ca2111a2df3707262
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
|
31
|
-
|
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
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
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(
|
60
|
+
def process(*, **)
|
60
61
|
reset_template_assertion
|
61
62
|
super
|
62
63
|
end
|
@@ -7,17 +7,19 @@ module Rails
|
|
7
7
|
module Controller
|
8
8
|
module Testing
|
9
9
|
def self.install
|
10
|
-
ActiveSupport.on_load(:
|
11
|
-
|
12
|
-
|
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
|
-
|
15
|
-
|
16
|
-
|
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(:
|
20
|
-
|
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
|
-
|
23
|
-
|
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
|