Skip to content

Commit 4d2beb7

Browse files
authored
Merge pull request rails#49856 from seanpdoyle/issue-49818
Rename `ActionView::TestCase::Behavior::{Content,RenderedViewContent}`
2 parents 64370c9 + cebbd1c commit 4d2beb7

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

actionview/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Rename `ActionView::TestCase::Behavior::{Content,RenderedViewContent}`
2+
3+
*Sean Doyle*
4+
15
* Raise `ArgumentError` when `nil` is passed as `model:` argument value to the `form_with` method.
26

37
*Collin Jilbert*

actionview/lib/action_view/test_case.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def include_helper_modules!
198198
end
199199

200200
included do
201-
class_attribute :content_class, instance_accessor: false, default: Content
201+
class_attribute :content_class, instance_accessor: false, default: RenderedViewContent
202202

203203
setup :setup_with_controller
204204

@@ -299,7 +299,7 @@ def _routes
299299
@controller._routes if @controller.respond_to?(:_routes)
300300
end
301301

302-
class Content < SimpleDelegator
302+
class RenderedViewContent < String # :nodoc:
303303
end
304304

305305
# Need to experiment if this priority is the best one: rendered => output_buffer

actionview/test/template/test_case_test.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ class CapybaraHTMLEncoderTest < ActionView::TestCase
369369
include ::Capybara::Minitest::Assertions
370370

371371
def page
372-
Capybara.string(document_root_element)
372+
Capybara.string(rendered)
373373
end
374374

375375
test "document_root_element can be configured to utilize Capybara" do
@@ -382,15 +382,16 @@ def page
382382
end
383383
end
384384

385-
class RenderedMethodMissingTest < ActionView::TestCase
386-
test "rendered delegates methods to the String" do
385+
class RenderedViewContentTest < ActionView::TestCase
386+
test "#rendered inherits from String" do
387387
developer = DeveloperStruct.new("Eloy")
388388

389389
render "developers/developer", developer: developer
390390

391+
assert_kind_of String, rendered
391392
assert_kind_of String, rendered.to_s
392393
assert_equal developer.name, rendered
393-
assert_match rendered, /#{developer.name}/
394+
assert_match(/#{developer.name}/, rendered)
394395
assert_includes rendered, developer.name
395396
end
396397
end

guides/source/testing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1797,7 +1797,7 @@ class ViewPartialTestCase < ActionView::TestCase
17971797
include Capybara::Minitest::Assertions
17981798
17991799
def page
1800-
Capybara.string(document_root_element)
1800+
Capybara.string(rendered)
18011801
end
18021802
end
18031803

0 commit comments

Comments
 (0)