-
Notifications
You must be signed in to change notification settings - Fork 59
Description
This is a dup of rails/rails#17008 in the right reposity
In a demo reproduction app, I have a controller that returns no layout:
class TestController < ApplicationController
def index
render :layout => false
end
end
It works, there is no layout, and no <body>
tag in the output (because I have no body
tag in my template, naturally, only in the layout).
However, in testing:
class TestControllerTest < ActionController::TestCase
test "no layout" do
get :index
# Assert that no layout was included in the request
assert_select "body", 0
end
end
returns:
1) Failure:
TestControllerTest#test_no_layout [/Users/jrochkind/code/rails42/test/controllers/test_controller_test.rb:11]:
Expected exactly 0 elements matching "body", found 1..
Expected: 0
Actual: 1
This doesn't seem to be right, trying to introspect on response.body
in the debugger, there appears to be no body
tag. But assert_select is for some reason insisting there is one.
This is an extraction from a real app that has a test to make sure no layout is provided in a case where one shouldn't be provided.
Sorry, I tried to follow the template for creating a self-contained repro, but couldn't manage to create a self-contained repro that had the assert_select
method available in a test, which is what I needed to demonstrate.