rails-intest-views 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +22 -0
- data/app/controllers/rails_intest_views/templates_controller.rb +12 -3
- data/lib/rails-intest-views/capybara_helpers.rb +5 -0
- data/lib/rails-intest-views/request_helpers.rb +5 -0
- data/lib/rails-intest-views/version.rb +1 -1
- data/lib/rails-intest-views.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbbb77038ece8edad24a39f87d7dcf3d906e181abdc42766b9f6d8728e48251e
|
4
|
+
data.tar.gz: a0a828e7d2fa1d78258812699c4c5ec95e866f843f50ab153b2e69c48b7872f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7137864811f78ffcac11d772e3187cd3d46a3b2f6b4842fb895b3351d7a96a8b7ea6d8b88e642c2b41bb0808318e24be1d6bc5e23dcbb520380ce933454a408
|
7
|
+
data.tar.gz: 68e694c069ed39065d9152e242e7b4d3a24d87b8aeca43eb6b4789ef449781ec49342d632e89074e562b08db5ba3296ba96deb479ca5ef88378a7eae4e5e0eb6
|
data/CHANGELOG.md
CHANGED
@@ -2,8 +2,13 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 0.2.0 (2023-12-12)
|
6
|
+
|
7
|
+
- Added support for Phlex and ViewComponent-type views and layouts. ([@dhnaranjo])
|
8
|
+
|
5
9
|
## 0.1.0 (2023-11-09)
|
6
10
|
|
7
11
|
- Initial release. ([@palkan][])
|
8
12
|
|
9
13
|
[@palkan]: https://github.com/palkan
|
14
|
+
[@dhnaranjo]: https://github.com/dhnaranjo
|
data/README.md
CHANGED
@@ -80,6 +80,28 @@ ERB
|
|
80
80
|
visit_template source, layout: "custom"
|
81
81
|
```
|
82
82
|
|
83
|
+
View components are supported through the `#render_component` helper:
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
button = ButtonComponent.new(type: :submit) do
|
87
|
+
"Save me!"
|
88
|
+
end
|
89
|
+
|
90
|
+
render_component button
|
91
|
+
```
|
92
|
+
|
93
|
+
View component-based layouts are supported as well:
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
button = ButtonComponent.new(type: :submit) do
|
97
|
+
"Save me!"
|
98
|
+
end
|
99
|
+
|
100
|
+
render_component button, layout: PreviewLayout
|
101
|
+
# or
|
102
|
+
render_component button, layout: -> { PreviewLayout }
|
103
|
+
```
|
104
|
+
|
83
105
|
### Configuration
|
84
106
|
|
85
107
|
The following configuration parameters are available (the default values are shown):
|
@@ -8,11 +8,20 @@ module RailsIntestViews
|
|
8
8
|
return head :not_found unless template_config
|
9
9
|
|
10
10
|
params = {
|
11
|
-
inline: template_config[:template]
|
12
|
-
layout: RailsIntestViews.config.default_layout
|
11
|
+
inline: template_config[:template]
|
13
12
|
}
|
14
13
|
|
15
|
-
params[:layout] =
|
14
|
+
params[:layout] = case template_config
|
15
|
+
in {layout: Class => klass}
|
16
|
+
proc { klass }
|
17
|
+
in {layout: Proc => lambda} if lambda.lambda?
|
18
|
+
contents = lambda.call
|
19
|
+
proc { contents }
|
20
|
+
in {layout: layout}
|
21
|
+
layout
|
22
|
+
else
|
23
|
+
RailsIntestViews.config.default_layout
|
24
|
+
end
|
16
25
|
|
17
26
|
render(**params)
|
18
27
|
end
|
@@ -6,5 +6,10 @@ module RailsIntestViews
|
|
6
6
|
id = RailsIntestViews.write(source, **options)
|
7
7
|
visit RailsIntestViews.url_for(id)
|
8
8
|
end
|
9
|
+
|
10
|
+
def visit_component(component, **options)
|
11
|
+
source = RailsIntestViews.render_component(component)
|
12
|
+
visit_template(source, **options)
|
13
|
+
end
|
9
14
|
end
|
10
15
|
end
|
@@ -6,5 +6,10 @@ module RailsIntestViews
|
|
6
6
|
id = RailsIntestViews.write(source, **options)
|
7
7
|
get RailsIntestViews.url_for(id)
|
8
8
|
end
|
9
|
+
|
10
|
+
def get_component(component, **options)
|
11
|
+
source = RailsIntestViews.render_component(component)
|
12
|
+
get_template(source, **options)
|
13
|
+
end
|
9
14
|
end
|
10
15
|
end
|
data/lib/rails-intest-views.rb
CHANGED
@@ -55,6 +55,11 @@ module RailsIntestViews
|
|
55
55
|
def url_for(id)
|
56
56
|
File.join(config.mount_path, id)
|
57
57
|
end
|
58
|
+
|
59
|
+
def render_component(component)
|
60
|
+
controller = config.templates_controller.constantize
|
61
|
+
controller.renderer.render_to_string(component)
|
62
|
+
end
|
58
63
|
end
|
59
64
|
|
60
65
|
autoload :RequestHelpers, "rails-intest-views/request_helpers"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-intest-views
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|