Skip to content

Commit

Permalink
Merge pull request #49856 from seanpdoyle/issue-49818
Browse files Browse the repository at this point in the history
Rename `ActionView::TestCase::Behavior::{Content,RenderedViewContent}`
  • Loading branch information
rafaelfranca committed Jan 4, 2024
2 parents 64370c9 + cebbd1c commit 4d2beb7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
4 changes: 4 additions & 0 deletions actionview/CHANGELOG.md
@@ -1,3 +1,7 @@
* Rename `ActionView::TestCase::Behavior::{Content,RenderedViewContent}`

*Sean Doyle*

* Raise `ArgumentError` when `nil` is passed as `model:` argument value to the `form_with` method.

*Collin Jilbert*
Expand Down
4 changes: 2 additions & 2 deletions actionview/lib/action_view/test_case.rb
Expand Up @@ -198,7 +198,7 @@ def include_helper_modules!
end

included do
class_attribute :content_class, instance_accessor: false, default: Content
class_attribute :content_class, instance_accessor: false, default: RenderedViewContent

setup :setup_with_controller

Expand Down Expand Up @@ -299,7 +299,7 @@ def _routes
@controller._routes if @controller.respond_to?(:_routes)
end

class Content < SimpleDelegator
class RenderedViewContent < String # :nodoc:
end

# Need to experiment if this priority is the best one: rendered => output_buffer
Expand Down
9 changes: 5 additions & 4 deletions actionview/test/template/test_case_test.rb
Expand Up @@ -369,7 +369,7 @@ class CapybaraHTMLEncoderTest < ActionView::TestCase
include ::Capybara::Minitest::Assertions

def page
Capybara.string(document_root_element)
Capybara.string(rendered)
end

test "document_root_element can be configured to utilize Capybara" do
Expand All @@ -382,15 +382,16 @@ def page
end
end

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

render "developers/developer", developer: developer

assert_kind_of String, rendered
assert_kind_of String, rendered.to_s
assert_equal developer.name, rendered
assert_match rendered, /#{developer.name}/
assert_match(/#{developer.name}/, rendered)
assert_includes rendered, developer.name
end
end
Expand Down
2 changes: 1 addition & 1 deletion guides/source/testing.md
Expand Up @@ -1797,7 +1797,7 @@ class ViewPartialTestCase < ActionView::TestCase
include Capybara::Minitest::Assertions

def page
Capybara.string(document_root_element)
Capybara.string(rendered)
end
end

Expand Down

0 comments on commit 4d2beb7

Please sign in to comment.