actionview-component 1.5.2 → 1.5.3
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 +4 -4
- data/CHANGELOG.md +10 -0
- data/Gemfile.lock +1 -1
- data/README.md +24 -0
- data/lib/action_view/component/railtie.rb +3 -15
- data/lib/action_view/component/version.rb +1 -1
- data/lib/rails/generators/rspec/component_generator.rb +19 -0
- data/lib/rails/generators/rspec/templates/component_spec.rb.tt +13 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00a684cf9aea1c6f1a94dd0c980fd7d1889e2b17fb165006817063de69b6f721
|
4
|
+
data.tar.gz: 30766fd4333fb8d708369e48192b000ba4a5136898bd82e98273d5fc9445fb67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aeaf7ae830c1b2e099a974228c0c072c41481c9ddd0f000c488727066df837f872b9616f064962bc3e8adee2fd20d86e0894d97cbc1a6c049faa5b6eea4636b1
|
7
|
+
data.tar.gz: ef32ebd537e7d36ae192b29b7aa756a8bf2efca96ef19d87e751e0dea11369616e0fc6e8a5848c2ea45230eb7eb46fac18e6e6eb6778ee58749193f22d3f2a44
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -260,6 +260,30 @@ For example, if you want to use `lib/component_previews`, set the following in `
|
|
260
260
|
config.action_view_component.preview_path = "#{Rails.root}/lib/component_previews"
|
261
261
|
```
|
262
262
|
|
263
|
+
### Setting up RSpec
|
264
|
+
|
265
|
+
If you're using RSpec, you can configure component specs to have access to test helpers. Add the following to
|
266
|
+
`spec/rails_helper.rb`:
|
267
|
+
|
268
|
+
```ruby
|
269
|
+
require "action_view/component/test_helpers"
|
270
|
+
|
271
|
+
RSpec.configure do |config|
|
272
|
+
# ...
|
273
|
+
|
274
|
+
# Ensure that the test helpers are available in component specs
|
275
|
+
config.include ActionView::Component::TestHelpers, type: :component
|
276
|
+
end
|
277
|
+
```
|
278
|
+
|
279
|
+
Specs created by the generator should now have access to test helpers like `render_inline`.
|
280
|
+
|
281
|
+
To use component previews, set the following in `config/application.rb`:
|
282
|
+
|
283
|
+
```ruby
|
284
|
+
config.action_view_component.preview_path = "#{Rails.root}/spec/components/previews"
|
285
|
+
```
|
286
|
+
|
263
287
|
## Frequently Asked Questions
|
264
288
|
|
265
289
|
### Can I use other templating languages besides ERB?
|
@@ -1,18 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "railties/lib/rails/components_controller"
|
4
|
-
require "railties/lib/rails/component_examples_controller"
|
5
|
-
|
6
3
|
module ActionView
|
7
4
|
module Component
|
8
5
|
class Railtie < Rails::Railtie # :nodoc:
|
9
6
|
config.action_view_component = ActiveSupport::OrderedOptions.new
|
10
7
|
|
11
|
-
# Disabled due to issues with ActionView::Component::Base not defining .logger
|
12
|
-
# initializer "action_view_component.logger" do
|
13
|
-
# ActiveSupport.on_load(:action_view_component) { self.logger ||= Rails.logger }
|
14
|
-
# end
|
15
|
-
|
16
8
|
initializer "action_view_component.set_configs" do |app|
|
17
9
|
options = app.config.action_view_component
|
18
10
|
|
@@ -28,6 +20,9 @@ module ActionView
|
|
28
20
|
end
|
29
21
|
|
30
22
|
initializer "action_view_component.set_autoload_paths" do |app|
|
23
|
+
require "railties/lib/rails/components_controller"
|
24
|
+
require "railties/lib/rails/component_examples_controller"
|
25
|
+
|
31
26
|
options = app.config.action_view_component
|
32
27
|
|
33
28
|
if options.show_previews && options.preview_path
|
@@ -41,13 +36,6 @@ module ActionView
|
|
41
36
|
end
|
42
37
|
end
|
43
38
|
|
44
|
-
# Disabled because `ActionView::Component::Base` doesn't implement `#action_methods`
|
45
|
-
# initializer "action_view_component.eager_load_actions" do
|
46
|
-
# ActiveSupport.on_load(:after_initialize) do
|
47
|
-
# ActionView::Component::Base.descendants.each(&:action_methods) if config.eager_load
|
48
|
-
# end
|
49
|
-
# end
|
50
|
-
|
51
39
|
config.after_initialize do |app|
|
52
40
|
options = app.config.action_view_component
|
53
41
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rspec
|
4
|
+
module Generators
|
5
|
+
class ComponentGenerator < ::Rails::Generators::NamedBase
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
7
|
+
|
8
|
+
def create_test_file
|
9
|
+
template "component_spec.rb", File.join("spec/components", "#{file_name}_component_spec.rb")
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def file_name
|
15
|
+
@_file_name ||= super.sub(/_component\z/i, "")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
RSpec.describe <%= class_name %>Component, type: :component do
|
4
|
+
pending "add some examples to (or delete) #{__FILE__}"
|
5
|
+
|
6
|
+
# it "renders something useful" do
|
7
|
+
# expect(
|
8
|
+
# render_inline(described_class, attr: "value") { "Hello, components!" }.css("p").to_html
|
9
|
+
# ).to include(
|
10
|
+
# "Hello, components!"
|
11
|
+
# )
|
12
|
+
# end
|
13
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actionview-component
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub Open Source
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -138,6 +138,8 @@ files:
|
|
138
138
|
- lib/rails/generators/component/component_generator.rb
|
139
139
|
- lib/rails/generators/component/templates/component.html.erb.tt
|
140
140
|
- lib/rails/generators/component/templates/component.rb.tt
|
141
|
+
- lib/rails/generators/rspec/component_generator.rb
|
142
|
+
- lib/rails/generators/rspec/templates/component_spec.rb.tt
|
141
143
|
- lib/rails/generators/test_unit/component_generator.rb
|
142
144
|
- lib/rails/generators/test_unit/templates/component_test.rb.tt
|
143
145
|
- lib/railties/lib/rails.rb
|