rails-integration-test-generator 0.1.1
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 +7 -0
- data/LICENSE +7 -0
- data/README.md +20 -0
- data/lib/generators/controller_integration_test_unit/controller/controller_generator.rb +15 -0
- data/lib/generators/controller_integration_test_unit/controller/templates/functional_test.rb.tt +23 -0
- data/lib/rails-integration-test-generator.rb +14 -0
- metadata +93 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 23a6fdcd5f1b67431256167313393d291f8fee97bc268613001ef7a37029f6ee
|
|
4
|
+
data.tar.gz: 242af09dc73d8a226b2c828ffcb502e795c4e26bcdfc634c5323bc69d70e0b34
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: d6f44d258da32511754111633d95a81c50fe6e821228594814e0338ae7b82ca85594bda87dc2ef104dcd09e8d98c5327c4b3ab4fe64fb204d6469b8ae77ddaf2
|
|
7
|
+
data.tar.gz: a2dabbc91a032794984a25e7940e9272ddfac9eacaae83a4e97b8bac5eae6a606e8c29a923b08e3543237990253bcd7e7fe2e1c63d2efb18fce2e9a9408a9891
|
data/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright (c) 2026 Patrick McSweeny
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# rails-integration-test-generator [](https://badge.fury.io/rb/rails-integration-test-generator) [](https://github.com/PatrickMcSweeny/rails-integration-test-generator/actions/workflows/main.yml)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
rails-integration-test generator overrides the controller generator to generate an integration test rather than the default controller test, which is really just a mislabeled integration test anyway.
|
|
5
|
+
|
|
6
|
+
## Usage
|
|
7
|
+
|
|
8
|
+
Just add this to your gemfile:
|
|
9
|
+
|
|
10
|
+
```ruby
|
|
11
|
+
gem 'rails-integration-test-generator'
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
This gem has been tested with Rails versions 7.0-8.1
|
|
15
|
+
|
|
16
|
+
Evertyime a controller is generated, an integration test will automatically be generated along with it.
|
|
17
|
+
|
|
18
|
+
## Rationale
|
|
19
|
+
|
|
20
|
+
Naming integration tests as controller tests is confusing and obscures their actual purpose, which is to test if various parts of an application integrate successfully.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ControllerIntegrationTestUnit
|
|
4
|
+
class ControllerGenerator < Rails::Generators::NamedBase # :nodoc:
|
|
5
|
+
source_root File.expand_path('templates', __dir__)
|
|
6
|
+
|
|
7
|
+
argument :actions, type: :array, default: [], banner: 'action action'
|
|
8
|
+
class_option :skip_routes, type: :boolean
|
|
9
|
+
|
|
10
|
+
def create_test_files
|
|
11
|
+
template 'functional_test.rb',
|
|
12
|
+
File.join('test/integration', class_path, "#{file_name}_test.rb")
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
data/lib/generators/controller_integration_test_unit/controller/templates/functional_test.rb.tt
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
|
|
3
|
+
<% module_namespacing do -%>
|
|
4
|
+
class <%= class_name %>Test < ActionDispatch::IntegrationTest
|
|
5
|
+
<% if mountable_engine? -%>
|
|
6
|
+
include Engine.routes.url_helpers
|
|
7
|
+
|
|
8
|
+
<% end -%>
|
|
9
|
+
<% if actions.empty? || options[:skip_routes] -%>
|
|
10
|
+
# test "the truth" do
|
|
11
|
+
# assert true
|
|
12
|
+
# end
|
|
13
|
+
<% else -%>
|
|
14
|
+
<% actions.each do |action| -%>
|
|
15
|
+
test "load <%= action %>" do
|
|
16
|
+
get <%= url_helper_prefix %>_<%= action %>_url
|
|
17
|
+
assert_response :success
|
|
18
|
+
end
|
|
19
|
+
<%= "\n" unless action == actions.last -%>
|
|
20
|
+
<% end -%>
|
|
21
|
+
<% end -%>
|
|
22
|
+
end
|
|
23
|
+
<% end -%>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rails'
|
|
4
|
+
|
|
5
|
+
module RailsIntegrationTestGenerator
|
|
6
|
+
module Rails
|
|
7
|
+
class Railtie < ::Rails::Railtie # :nodoc:
|
|
8
|
+
config.app_generators do |g|
|
|
9
|
+
g.test_framework :controller_integration_test_unit, fixture: false
|
|
10
|
+
g.fallbacks[:controller_integration_test_unit] = :test_unit
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: rails-integration-test-generator
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Patrick McSweeny
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: railties
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '7.0'
|
|
19
|
+
- - "<="
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '8.1'
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
requirements:
|
|
26
|
+
- - ">="
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
version: '7.0'
|
|
29
|
+
- - "<="
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
31
|
+
version: '8.1'
|
|
32
|
+
- !ruby/object:Gem::Dependency
|
|
33
|
+
name: rails
|
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - ">="
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '7.0'
|
|
39
|
+
type: :development
|
|
40
|
+
prerelease: false
|
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
42
|
+
requirements:
|
|
43
|
+
- - ">="
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '7.0'
|
|
46
|
+
- !ruby/object:Gem::Dependency
|
|
47
|
+
name: rake
|
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
|
49
|
+
requirements:
|
|
50
|
+
- - ">="
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: '0'
|
|
53
|
+
type: :development
|
|
54
|
+
prerelease: false
|
|
55
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
56
|
+
requirements:
|
|
57
|
+
- - ">="
|
|
58
|
+
- !ruby/object:Gem::Version
|
|
59
|
+
version: '0'
|
|
60
|
+
description: Overrides rails controller generator to generate an integration test
|
|
61
|
+
instead of a controller test
|
|
62
|
+
email: patmcsweeny@gmail.com
|
|
63
|
+
executables: []
|
|
64
|
+
extensions: []
|
|
65
|
+
extra_rdoc_files: []
|
|
66
|
+
files:
|
|
67
|
+
- LICENSE
|
|
68
|
+
- README.md
|
|
69
|
+
- lib/generators/controller_integration_test_unit/controller/controller_generator.rb
|
|
70
|
+
- lib/generators/controller_integration_test_unit/controller/templates/functional_test.rb.tt
|
|
71
|
+
- lib/rails-integration-test-generator.rb
|
|
72
|
+
homepage: https://github.com/PatrickMcSweeny/rails-integration-test-generator
|
|
73
|
+
licenses:
|
|
74
|
+
- MIT
|
|
75
|
+
metadata: {}
|
|
76
|
+
rdoc_options: []
|
|
77
|
+
require_paths:
|
|
78
|
+
- lib
|
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
80
|
+
requirements:
|
|
81
|
+
- - ">="
|
|
82
|
+
- !ruby/object:Gem::Version
|
|
83
|
+
version: 2.7.0
|
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - ">="
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '0'
|
|
89
|
+
requirements: []
|
|
90
|
+
rubygems_version: 3.6.9
|
|
91
|
+
specification_version: 4
|
|
92
|
+
summary: Generates integration test instead of controller tests
|
|
93
|
+
test_files: []
|