File tree Expand file tree Collapse file tree 4 files changed +45
-21
lines changed Expand file tree Collapse file tree 4 files changed +45
-21
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,19 @@ RSpec.configure do |config|
40
40
end
41
41
```
42
42
43
+ ## Outside Rails
44
+
45
+ For projects and gems using controller tests outside of a Rails application,
46
+ invoke the ` Rails::Controller::Testing.install ` method inside your test suite
47
+ setup to include the required modules on controller test cases.
48
+
49
+ ``` ruby
50
+ # test/test_helper.rb
51
+
52
+ require ' rails-controller-testing'
53
+ Rails ::Controller ::Testing .install
54
+ ```
55
+
43
56
## Usage
44
57
45
58
### assigns
Original file line number Diff line number Diff line change 1
- require 'active_support/lazy_load_hooks'
2
- require 'rails/controller/testing/test_process'
3
- require 'rails/controller/testing/integration'
4
- require 'rails/controller/testing/template_assertions'
1
+ require 'rails/controller/testing'
2
+ require 'rails/controller/testing/railtie' if defined? ( Rails ::Railtie )
5
3
require 'rails/controller/testing/version'
6
-
7
- class Rails ::Controller ::Testing ::Railtie < Rails ::Railtie
8
- initializer "rails_controller_testing" do
9
- ActiveSupport . on_load ( :action_controller ) do
10
- ActionController ::TestCase . include Rails ::Controller ::Testing ::TestProcess
11
- ActionController ::TestCase . include Rails ::Controller ::Testing ::TemplateAssertions
12
-
13
- ActionDispatch ::IntegrationTest . include Rails ::Controller ::Testing ::TemplateAssertions
14
- ActionDispatch ::IntegrationTest . include Rails ::Controller ::Testing ::Integration
15
- ActionDispatch ::IntegrationTest . include Rails ::Controller ::Testing ::TestProcess
16
- end
17
-
18
- ActiveSupport . on_load ( :action_view ) do
19
- ActionView ::TestCase . include Rails ::Controller ::Testing ::TemplateAssertions
20
- end
21
- end
22
- end
Original file line number Diff line number Diff line change
1
+ require 'active_support/lazy_load_hooks'
2
+ require 'rails/controller/testing/test_process'
3
+ require 'rails/controller/testing/integration'
4
+ require 'rails/controller/testing/template_assertions'
5
+
6
+ module Rails
7
+ module Controller
8
+ module Testing
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
13
+
14
+ ActionDispatch ::IntegrationTest . include Rails ::Controller ::Testing ::TemplateAssertions
15
+ ActionDispatch ::IntegrationTest . include Rails ::Controller ::Testing ::Integration
16
+ ActionDispatch ::IntegrationTest . include Rails ::Controller ::Testing ::TestProcess
17
+ end
18
+
19
+ ActiveSupport . on_load ( :action_view ) do
20
+ ActionView ::TestCase . include Rails ::Controller ::Testing ::TemplateAssertions
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
Original file line number Diff line number Diff line change
1
+ class Rails ::Controller ::Testing ::Railtie < Rails ::Railtie
2
+ initializer "rails_controller_testing" do
3
+ Rails ::Controller ::Testing . install
4
+ end
5
+ end
You can’t perform that action at this time.
0 commit comments