view_component 2.61.0 → 2.61.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f46bf10c68e5273401ec52134ae2cf55d844f9b01c55121e082146364194e144
4
- data.tar.gz: 81ec5867c81158b0c06fdab309674f2f5a9cef7cf0546575308084ac928116c6
3
+ metadata.gz: f405812996b460c943dba2ae0802dbc7e924ce3ae45ff69eb917333c77ecb890
4
+ data.tar.gz: b50121e18674aa4c5f7b569cc4c2edb5078d4685192e8154d4654b4b21a03ef6
5
5
  SHA512:
6
- metadata.gz: 05450d5c3e5376fe7aa4a2a934ee2b7179cafb91681cf1b6ed7f1469bd3db29f92d0ba6e96930e36403f7e250a3b7b8aeb7cc061aa30954d2d8524c6d7081d6b
7
- data.tar.gz: 91101a168fee89fd23dad833c769027db7022a852b07b918d427b40a8b1997b861827724f7390dd470f4e69e1a8351638a43cd2d34f6df9bf20c64be0eb61d43
6
+ metadata.gz: 23b295998753b2f0d17af1ee5cbc18ec0602cafa48c1ca4ee19568073c38453c79b7aadd1ec42160eab0b522d4a5c3c10f8682a224ed771b4ff25da1e97730fa
7
+ data.tar.gz: 43e4f27eb614d7de04e6b44747e4d7f2c006367cae62b2b3dc7ad67bdc6a22ea9ea7822308895b704bd19a50879d3bb3ecf2f0209adb9f039eb149217ef479b5
data/docs/CHANGELOG.md CHANGED
@@ -9,6 +9,20 @@ title: Changelog
9
9
 
10
10
  ## main
11
11
 
12
+ ## 2.61.1
13
+
14
+ * Revert `Expose Capybara DSL methods directly inside tests.` This change unintentionally broke other Capybara methods and thus introduced a regression. We aren't confident that we can fail forward so we have decided to revert this change.
15
+
16
+ *Joel Hawksley*, *Blake Williams*
17
+
18
+ * Revert change making content evaluation consistent.
19
+
20
+ *Blake Williams*
21
+
22
+ * Pin `rails` `main` dependency due to incompatibility with Global Output Buffer.
23
+
24
+ *Joel Hawksley*
25
+
12
26
  ## 2.61.0
13
27
 
14
28
  * Ensure side-effects in `content` are consistently evaluated before components are rendered. This change effectively means that `content` is evaluated for every component render where `render?` returns true. As a result, code that is passed to a component via a block/content will now always be evaluated, before `#call`, which can reveal bugs in existing components.
@@ -124,10 +124,6 @@ module ViewComponent
124
124
  before_render
125
125
 
126
126
  if render?
127
- # preload content to support slot delegation and to consistently perform
128
- # side-effects that may exist in the block
129
- content
130
-
131
127
  perform_render
132
128
  else
133
129
  ""
@@ -10,7 +10,7 @@ module ViewComponent
10
10
  location = Kernel.caller_locations(1, 1)[0]
11
11
 
12
12
  warn(
13
- "warning: ViewComponent::PolymorphicSlots is now included in ViewComponent::Base by default "\
13
+ "warning: ViewComponent::PolymorphicSlots is now included in ViewComponent::Base by default " \
14
14
  "and can be removed from #{location.path}:#{location.lineno}"
15
15
  )
16
16
  # :nocov:
@@ -58,7 +58,7 @@ module ViewComponent
58
58
 
59
59
  define_method(setter_name) do |*args, &block|
60
60
  ViewComponent::Deprecation.warn(
61
- "polymorphic slot setters like `#{setter_name}` are deprecated and will be removed in"\
61
+ "polymorphic slot setters like `#{setter_name}` are deprecated and will be removed in" \
62
62
  "ViewComponent v3.0.0.\n\nUse `with_#{setter_name}` instead."
63
63
  )
64
64
 
@@ -266,8 +266,8 @@ module ViewComponent
266
266
  def raise_if_slot_ends_with_question_mark(slot_name)
267
267
  if slot_name.to_s.ends_with?("?")
268
268
  raise ArgumentError.new(
269
- "#{self} declares a slot named #{slot_name}, which ends with a question mark.\n\n"\
270
- "This is not allowed because the ViewComponent framework already provides predicate "\
269
+ "#{self} declares a slot named #{slot_name}, which ends with a question mark.\n\n" \
270
+ "This is not allowed because the ViewComponent framework already provides predicate " \
271
271
  "methods ending in `?`.\n\n" \
272
272
  "To fix this issue, choose a different name."
273
273
  )
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "view_component/render_preview_helper"
4
- require "view_component/capybara_simple_session"
5
4
 
6
5
  module ViewComponent
7
6
  module TestHelpers
@@ -10,28 +9,8 @@ module ViewComponent
10
9
 
11
10
  include Capybara::Minitest::Assertions
12
11
 
13
- CapybaraSimpleSession::DSL_METHODS.each do |method|
14
- if RUBY_VERSION >= "2.7"
15
- class_eval <<~METHOD, __FILE__, __LINE__ + 1
16
- def #{method}(...)
17
- page.method("#{method}").call(...)
18
- end
19
- METHOD
20
- else
21
- define_method method do |*args, &block|
22
- page.send method, *args, &block
23
- end
24
- end
25
- end
26
-
27
- def self.included(mod)
28
- Capybara::Node::Simple.send(:define_method, :to_capybara_node) do
29
- self
30
- end
31
- end
32
-
33
12
  def page
34
- @page ||= CapybaraSimpleSession.new(rendered_content)
13
+ @page ||= Capybara::Node::Simple.new(rendered_content)
35
14
  end
36
15
 
37
16
  def refute_component_rendered
@@ -4,7 +4,7 @@ module ViewComponent
4
4
  module VERSION
5
5
  MAJOR = 2
6
6
  MINOR = 61
7
- PATCH = 0
7
+ PATCH = 1
8
8
 
9
9
  STRING = [MAJOR, MINOR, PATCH].join(".")
10
10
  end
@@ -7,7 +7,6 @@ module ViewComponent
7
7
  extend ActiveSupport::Autoload
8
8
 
9
9
  autoload :Base
10
- autoload :CapybaraSimpleSession
11
10
  autoload :Compiler
12
11
  autoload :CompileCache
13
12
  autoload :ComponentError
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: 2.61.0
4
+ version: 2.61.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Open Source
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-18 00:00:00.000000000 Z
11
+ date: 2022-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -325,7 +325,6 @@ files:
325
325
  - lib/rails/generators/test_unit/templates/component_test.rb.tt
326
326
  - lib/view_component.rb
327
327
  - lib/view_component/base.rb
328
- - lib/view_component/capybara_simple_session.rb
329
328
  - lib/view_component/collection.rb
330
329
  - lib/view_component/compile_cache.rb
331
330
  - lib/view_component/compiler.rb
@@ -1,132 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ViewComponent
4
- # This is a simpler version of {Capybara::Session}.
5
- #
6
- # It only includes {Capybara::Node::Finders}, {Capybara::Node::Matchers},
7
- # {#within} and {#within_element}. It is useful in that it does not require a
8
- # session, an application or a driver, but can still use Capybara's finders
9
- # and matchers on any string that contains HTML.
10
- class CapybaraSimpleSession
11
- # Most of the code in this class is shamelessly stolen from the
12
- # {Capybara::Session} class in the Capybara gem
13
- # (https://github.com/teamcapybara/capybara/blob/e704d00879fb1d1e1a0cc01e04c101bcd8af4a68/lib/capybara/session.rb#L38).
14
-
15
- NODE_METHODS = %i[
16
- all
17
- first
18
- text
19
-
20
- find
21
- find_all
22
- find_button
23
- find_by_id
24
- find_field
25
- find_link
26
-
27
- has_content?
28
- has_text?
29
- has_css?
30
- has_no_content?
31
- has_no_text?
32
- has_no_css?
33
- has_no_xpath?
34
- has_xpath?
35
- has_link?
36
- has_no_link?
37
- has_button?
38
- has_no_button?
39
- has_field?
40
- has_no_field?
41
- has_checked_field?
42
- has_unchecked_field?
43
- has_no_table?
44
- has_table?
45
- has_select?
46
- has_no_select?
47
- has_selector?
48
- has_no_selector?
49
- has_no_checked_field?
50
- has_no_unchecked_field?
51
-
52
- assert_selector
53
- assert_no_selector
54
- assert_all_of_selectors
55
- assert_none_of_selectors
56
- assert_any_of_selectors
57
- assert_text
58
- assert_no_text
59
- ].freeze
60
-
61
- private_constant :NODE_METHODS
62
-
63
- SESSION_METHODS = %i[within within_element within_fieldset within_table].freeze
64
-
65
- private_constant :SESSION_METHODS
66
-
67
- DSL_METHODS = (NODE_METHODS + SESSION_METHODS).freeze
68
-
69
- # Stolen from: https://github.com/teamcapybara/capybara/blob/e704d00879fb1d1e1a0cc01e04c101bcd8af4a68/lib/capybara/session.rb#L767-L774.
70
- NODE_METHODS.each do |method|
71
- if RUBY_VERSION >= "2.7"
72
- class_eval <<~METHOD, __FILE__, __LINE__ + 1
73
- def #{method}(...)
74
- current_scope.#{method}(...)
75
- end
76
- METHOD
77
- else
78
- define_method method do |*args, &block|
79
- current_scope.send(method, *args, &block)
80
- end
81
- end
82
- end
83
-
84
- # Initializes the receiver with the given string of HTML.
85
- #
86
- # @param html [String] the HTML to create the session out of
87
- def initialize(html)
88
- @document = Capybara::Node::Simple.new(html)
89
- end
90
-
91
- # (see Capybara::Session#within)
92
- def within(*args, **kw_args)
93
- new_scope = args.first.respond_to?(:to_capybara_node) ? args.first.to_capybara_node : find(*args, **kw_args)
94
- begin
95
- scopes.push(new_scope)
96
- yield if block_given?
97
- ensure
98
- scopes.pop
99
- end
100
- end
101
-
102
- # (see Capybara::Session#within_element)
103
- alias_method :within_element, :within
104
-
105
- # (see Capybara::Session#within_fieldset)
106
- def within_fieldset(locator, &block)
107
- within(:fieldset, locator, &block)
108
- end
109
-
110
- # (see Capybara::Session#within_table)
111
- def within_table(locator, &block)
112
- within(:table, locator, &block)
113
- end
114
-
115
- # (see Capybara::Node::Element#native)
116
- def native
117
- current_scope.native
118
- end
119
-
120
- private
121
-
122
- attr_reader :document
123
-
124
- def scopes
125
- @scopes ||= [nil]
126
- end
127
-
128
- def current_scope
129
- scopes.last.presence || document
130
- end
131
- end
132
- end