view_component 3.10.0 → 3.12.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3f4f53b04ea58ed971bef33e1bea8ab65c2564c64a49927ca5db90c118d23bc
4
- data.tar.gz: 1a6b6024ffd5baf72cb80726b0853cf3fcab80d43505c87648cc57d6726e9185
3
+ metadata.gz: c9624272c360c4807dd67cd51f1ac1c1ffa9eab79cfb77994768ef32c8cb6af0
4
+ data.tar.gz: f393224b193af373eef5333a35fc20ac8ca8d5501716d0c3a58aeea0ad56de61
5
5
  SHA512:
6
- metadata.gz: 0f75de114591fca8e662e6fa15086c0b6b11c5862a05e68abff123ba19b7b23b7f67e7b65f8adca8a78688011254117643e9f0e76b92e5a0c0c51d82ecb85194
7
- data.tar.gz: 9771fc3c30b8472bb2f0793573926cd7b05e8f991091af18f8e51cfd5370ea8ac7f1eff40488eb0e1434a81683e901fcd74659763620f2e5ae8a26d4db0c943b
6
+ metadata.gz: dfa57ba053fac0733672492bee096d2b009dea6e5931e38ecb300d7eabe4d90a73966d81373dc7bbc1f61bcf074fc2e803611eb6602554b649b9f54a9a4ea471
7
+ data.tar.gz: c8bf7fbbc161ce4030e7529bd7c5c7053d3c16f6c7f92a2816abce0727ceeacbce12d6b757faa107b3e24b92f6c423875afce3c50008d049aca45716c5be2dff
data/docs/CHANGELOG.md CHANGED
@@ -10,6 +10,56 @@ nav_order: 5
10
10
 
11
11
  ## main
12
12
 
13
+ ## 3.12.0
14
+
15
+ * Remove offline links from resources.
16
+
17
+ *Paulo Henrique Meneses*
18
+
19
+ * Fix templates not being correctly populated when caller location label has a prefix.
20
+
21
+ On the upstream version of Ruby, method owners are now included in backtraces as prefixes. This caused the call stack filtering to not work as intended and thus `source_location` to be incorrect for child ViewComponents, consequently not populating templates correctly.
22
+
23
+ *Allan Pires, Jason Kim*
24
+
25
+ * Use component path for generating RSpec files.
26
+
27
+ When generating new RSpec files for components, the generator will use the `view_component_path` value in the config to decide where to put the new spec file. For instance, if the `view_component_path` option has been changed to `app/views/components`, the generator will put the spec file in `spec/views/components`. **If the `view_component_path` doesn't start with `app/`, then the generator will fall back to `spec/components/`.**
28
+
29
+ This feature is enabled via the `config.view_component.generate.use_component_path_for_rspec_tests` option, defaulting to `false`. The default will change to `true` in ViewComponent v4.
30
+
31
+ *William Mathewson*
32
+
33
+ ## 3.11.0
34
+
35
+ * Fix running non-integration tests under Rails main.
36
+
37
+ *Cameron Dutro*
38
+
39
+ * Better name and link for Avo.
40
+
41
+ *Adrian Marin*
42
+
43
+ * Document using rack-mini-profiler with ViewComponent.
44
+
45
+ *Thomas Carr*
46
+
47
+ * Move dependencies to gemspec.
48
+
49
+ *Joel Hawksley*
50
+
51
+ * Include ViewComponent::UseHelpers by default.
52
+
53
+ *Reegan Viljoen*
54
+
55
+ * Bump `puma` in Gemfile.lock.
56
+
57
+ *Cameron Dutro*
58
+
59
+ * Add Keenly to users list.
60
+
61
+ *Vinoth*
62
+
13
63
  ## 3.10.0
14
64
 
15
65
  * Fix html escaping in `#call` for non-strings.
@@ -1,18 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "rails/generators/abstract_generator"
4
+
3
5
  module Rspec
4
6
  module Generators
5
7
  class ComponentGenerator < ::Rails::Generators::NamedBase
8
+ include ViewComponent::AbstractGenerator
9
+
6
10
  source_root File.expand_path("templates", __dir__)
7
11
 
8
12
  def create_test_file
9
- template "component_spec.rb", File.join("spec/components", class_path, "#{file_name}_component_spec.rb")
13
+ template "component_spec.rb", File.join(spec_component_path, class_path, "#{file_name}_component_spec.rb")
10
14
  end
11
15
 
12
16
  private
13
17
 
14
- def file_name
15
- @_file_name ||= super.sub(/_component\z/i, "")
18
+ def spec_component_path
19
+ return "spec/components" unless ViewComponent::Base.config.generate.use_component_path_for_rspec_tests
20
+
21
+ configured_component_path = component_path
22
+ if configured_component_path.start_with?("app#{File::SEPARATOR}")
23
+ _app, *rest_of_path = Pathname.new(configured_component_path).each_filename.to_a
24
+ File.join("spec", *rest_of_path)
25
+ else
26
+ "spec/components"
27
+ end
16
28
  end
17
29
  end
18
30
  end
@@ -28,6 +28,7 @@ module ViewComponent
28
28
  end
29
29
 
30
30
  include ViewComponent::InlineTemplate
31
+ include ViewComponent::UseHelpers
31
32
  include ViewComponent::Slotable
32
33
  include ViewComponent::Translatable
33
34
  include ViewComponent::WithContentHelper
@@ -536,7 +537,9 @@ module ViewComponent
536
537
  # Derive the source location of the component Ruby file from the call stack.
537
538
  # We need to ignore `inherited` frames here as they indicate that `inherited`
538
539
  # has been re-defined by the consuming application, likely in ApplicationComponent.
539
- child.source_location = caller_locations(1, 10).reject { |l| l.label == "inherited" }[0].path
540
+ # We use `base_label` method here instead of `label` to avoid cases where the method
541
+ # owner is included in a prefix like `ApplicationComponent.inherited`.
542
+ child.source_location = caller_locations(1, 10).reject { |l| l.base_label == "inherited" }[0].path
540
543
 
541
544
  # If Rails application is loaded, removes the first part of the path and the extension.
542
545
  if defined?(Rails) && Rails.application
@@ -79,6 +79,19 @@ module ViewComponent
79
79
  # Defaults to `""`. If this is blank, the generator will use
80
80
  # `ViewComponent.config.preview_paths` if defined,
81
81
  # `"test/components/previews"` otherwise
82
+ #
83
+ # #### `#use_component_path_for_rspec_tests`
84
+ #
85
+ # Whether to use the `config.view_component_path` when generating new
86
+ # RSpec component tests:
87
+ #
88
+ # config.view_component.generate.use_component_path_for_rspec_tests = true
89
+ #
90
+ # When set to `true`, the generator will use the `view_component_path` to
91
+ # decide where to generate the new RSpec component test.
92
+ # For example, if the `view_component_path` is
93
+ # `app/views/components`, then the generator will create a new spec file
94
+ # in `spec/views/components/` rather than the default `spec/components/`.
82
95
 
83
96
  # @!attribute preview_controller
84
97
  # @return [String]
@@ -366,7 +366,7 @@ module ViewComponent
366
366
  # 1. If this is a `content_area` style sub-component, we will render the
367
367
  # block via the `slot`
368
368
  #
369
- # 2. Since we've to pass block content to components when calling
369
+ # 2. Since we have to pass block content to components when calling
370
370
  # `render`, evaluating the block here would require us to call
371
371
  # `view_context.capture` twice, which is slower
372
372
  slot.__vc_content_block = block if block
@@ -238,6 +238,8 @@ module ViewComponent
238
238
  #
239
239
  # @return [ActionDispatch::TestRequest]
240
240
  def vc_test_request
241
+ require "action_controller/test_case"
242
+
241
243
  @vc_test_request ||=
242
244
  begin
243
245
  out = ActionDispatch::TestRequest.create
@@ -3,7 +3,7 @@
3
3
  module ViewComponent
4
4
  module VERSION
5
5
  MAJOR = 3
6
- MINOR = 10
6
+ MINOR = 12
7
7
  PATCH = 0
8
8
  PRE = nil
9
9
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: view_component
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.10.0
4
+ version: 3.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ViewComponent Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-09 00:00:00.000000000 Z
11
+ date: 2024-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -114,6 +114,48 @@ dependencies:
114
114
  - - "~>"
115
115
  - !ruby/object:Gem::Version
116
116
  version: '2'
117
+ - !ruby/object:Gem::Dependency
118
+ name: capybara
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '3'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '3'
131
+ - !ruby/object:Gem::Dependency
132
+ name: cuprite
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: '0.15'
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: '0.15'
145
+ - !ruby/object:Gem::Dependency
146
+ name: debug
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
117
159
  - !ruby/object:Gem::Dependency
118
160
  name: erb_lint
119
161
  requirement: !ruby/object:Gem::Requirement
@@ -198,6 +240,20 @@ dependencies:
198
240
  - - "~>"
199
241
  - !ruby/object:Gem::Version
200
242
  version: '0.13'
243
+ - !ruby/object:Gem::Dependency
244
+ name: puma
245
+ requirement: !ruby/object:Gem::Requirement
246
+ requirements:
247
+ - - "~>"
248
+ - !ruby/object:Gem::Version
249
+ version: '6'
250
+ type: :development
251
+ prerelease: false
252
+ version_requirements: !ruby/object:Gem::Requirement
253
+ requirements:
254
+ - - "~>"
255
+ - !ruby/object:Gem::Version
256
+ version: '6'
201
257
  - !ruby/object:Gem::Dependency
202
258
  name: rake
203
259
  requirement: !ruby/object:Gem::Requirement
@@ -212,6 +268,20 @@ dependencies:
212
268
  - - "~>"
213
269
  - !ruby/object:Gem::Version
214
270
  version: '13.0'
271
+ - !ruby/object:Gem::Dependency
272
+ name: rspec-rails
273
+ requirement: !ruby/object:Gem::Requirement
274
+ requirements:
275
+ - - "~>"
276
+ - !ruby/object:Gem::Version
277
+ version: '5'
278
+ type: :development
279
+ prerelease: false
280
+ version_requirements: !ruby/object:Gem::Requirement
281
+ requirements:
282
+ - - "~>"
283
+ - !ruby/object:Gem::Version
284
+ version: '5'
215
285
  - !ruby/object:Gem::Dependency
216
286
  name: rubocop-md
217
287
  requirement: !ruby/object:Gem::Requirement
@@ -226,6 +296,20 @@ dependencies:
226
296
  - - "~>"
227
297
  - !ruby/object:Gem::Version
228
298
  version: '1'
299
+ - !ruby/object:Gem::Dependency
300
+ name: selenium-webdriver
301
+ requirement: !ruby/object:Gem::Requirement
302
+ requirements:
303
+ - - '='
304
+ - !ruby/object:Gem::Version
305
+ version: 4.9.0
306
+ type: :development
307
+ prerelease: false
308
+ version_requirements: !ruby/object:Gem::Requirement
309
+ requirements:
310
+ - - '='
311
+ - !ruby/object:Gem::Version
312
+ version: 4.9.0
229
313
  - !ruby/object:Gem::Dependency
230
314
  name: standard
231
315
  requirement: !ruby/object:Gem::Requirement
@@ -296,6 +380,20 @@ dependencies:
296
380
  - - "~>"
297
381
  - !ruby/object:Gem::Version
298
382
  version: 3.4.2
383
+ - !ruby/object:Gem::Dependency
384
+ name: warning
385
+ requirement: !ruby/object:Gem::Requirement
386
+ requirements:
387
+ - - ">="
388
+ - !ruby/object:Gem::Version
389
+ version: '0'
390
+ type: :development
391
+ prerelease: false
392
+ version_requirements: !ruby/object:Gem::Requirement
393
+ requirements:
394
+ - - ">="
395
+ - !ruby/object:Gem::Version
396
+ version: '0'
299
397
  - !ruby/object:Gem::Dependency
300
398
  name: yard
301
399
  requirement: !ruby/object:Gem::Requirement
@@ -324,6 +422,48 @@ dependencies:
324
422
  - - "~>"
325
423
  - !ruby/object:Gem::Version
326
424
  version: 0.0.1
425
+ - !ruby/object:Gem::Dependency
426
+ name: net-imap
427
+ requirement: !ruby/object:Gem::Requirement
428
+ requirements:
429
+ - - ">="
430
+ - !ruby/object:Gem::Version
431
+ version: '0'
432
+ type: :development
433
+ prerelease: false
434
+ version_requirements: !ruby/object:Gem::Requirement
435
+ requirements:
436
+ - - ">="
437
+ - !ruby/object:Gem::Version
438
+ version: '0'
439
+ - !ruby/object:Gem::Dependency
440
+ name: net-pop
441
+ requirement: !ruby/object:Gem::Requirement
442
+ requirements:
443
+ - - ">="
444
+ - !ruby/object:Gem::Version
445
+ version: '0'
446
+ type: :development
447
+ prerelease: false
448
+ version_requirements: !ruby/object:Gem::Requirement
449
+ requirements:
450
+ - - ">="
451
+ - !ruby/object:Gem::Version
452
+ version: '0'
453
+ - !ruby/object:Gem::Dependency
454
+ name: net-smtp
455
+ requirement: !ruby/object:Gem::Requirement
456
+ requirements:
457
+ - - ">="
458
+ - !ruby/object:Gem::Version
459
+ version: '0'
460
+ type: :development
461
+ prerelease: false
462
+ version_requirements: !ruby/object:Gem::Requirement
463
+ requirements:
464
+ - - ">="
465
+ - !ruby/object:Gem::Version
466
+ version: '0'
327
467
  description:
328
468
  email:
329
469
  executables: []
@@ -421,7 +561,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
421
561
  - !ruby/object:Gem::Version
422
562
  version: '0'
423
563
  requirements: []
424
- rubygems_version: 3.5.3
564
+ rubygems_version: 3.5.4
425
565
  signing_key:
426
566
  specification_version: 4
427
567
  summary: A framework for building reusable, testable & encapsulated view components