actionview-component 1.5.2 → 1.5.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30c2d62abc3a38ba7f383a934ea3a95d6e490f81868d062d9263130e6d694d84
4
- data.tar.gz: 8cc4375853920bd79183e9e634e00a9f4804726c2fc2a60328f3f1ad664bccef
3
+ metadata.gz: 00a684cf9aea1c6f1a94dd0c980fd7d1889e2b17fb165006817063de69b6f721
4
+ data.tar.gz: 30766fd4333fb8d708369e48192b000ba4a5136898bd82e98273d5fc9445fb67
5
5
  SHA512:
6
- metadata.gz: 98e2021c3308374c1ef1d92d044b18bdcbb071e422a52cbfe102f984cbf34521d6c19b4f9b60b511f3f9ffa1e3b2e0fc7b5ec31dcf22420f5d4240baad42e881
7
- data.tar.gz: 7e68770c3ec42381c7fce1028834b95ce4c6d04e1ce71e2849ce04a99b73b3539c2246c35bd77421a63c754e66fac083adaac1ae531bc37fb306293cd7a9a61e
6
+ metadata.gz: aeaf7ae830c1b2e099a974228c0c072c41481c9ddd0f000c488727066df837f872b9616f064962bc3e8adee2fd20d86e0894d97cbc1a6c049faa5b6eea4636b1
7
+ data.tar.gz: ef32ebd537e7d36ae192b29b7aa756a8bf2efca96ef19d87e751e0dea11369616e0fc6e8a5848c2ea45230eb7eb46fac18e6e6eb6778ee58749193f22d3f2a44
@@ -1,3 +1,13 @@
1
+ # v1.5.3
2
+
3
+ * Add support for RSpec to generators.
4
+
5
+ *Dylan Clark, Ryan Workman*
6
+
7
+ * Require controllers as part of setting autoload paths.
8
+
9
+ *Joel Hawksley*
10
+
1
11
  # v1.5.2
2
12
 
3
13
  * Disable eager loading initializer.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- actionview-component (1.5.2)
4
+ actionview-component (1.5.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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
 
@@ -5,7 +5,7 @@ module ActionView
5
5
  module VERSION
6
6
  MAJOR = 1
7
7
  MINOR = 5
8
- PATCH = 2
8
+ PATCH = 3
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH].join(".")
11
11
  end
@@ -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.2
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-22 00:00:00.000000000 Z
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