Skip to content

Commit a984ee1

Browse files
committed
1 parent ee7cf8c commit a984ee1

20 files changed

+298
-277
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ group :test do
113113
gem "minitest-bisect"
114114
gem "minitest-retry"
115115
gem "minitest-reporters"
116+
gem "rails-dom-testing", github: "rails/rails-dom-testing", branch: "master"
116117

117118
platforms :mri do
118119
gem "stackprof"

Gemfile.lock

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ GIT
2020
event_emitter
2121
websocket
2222

23+
GIT
24+
remote: https://github.com/rails/rails-dom-testing.git
25+
revision: 267487e20588d3848def3f8a3663fba5b740c9da
26+
branch: master
27+
specs:
28+
rails-dom-testing (2.0.3)
29+
activesupport (>= 5.0.0)
30+
nokogiri (>= 1.6)
31+
2332
GIT
2433
remote: https://github.com/resque/redis-namespace.git
2534
revision: c31e63dc3cd5e59ef5ea394d4d46ac60d1e6f82e
@@ -388,6 +397,7 @@ GEM
388397
thor
389398
raabro (1.4.0)
390399
racc (1.5.2)
400+
racc (1.5.2-java)
391401
rack (2.2.3)
392402
rack-cache (1.12.1)
393403
rack (>= 0.4)
@@ -397,9 +407,6 @@ GEM
397407
rack
398408
rack-test (1.1.0)
399409
rack (>= 1.0, < 3)
400-
rails-dom-testing (2.0.3)
401-
activesupport (>= 4.2.0)
402-
nokogiri (>= 1.6)
403410
rails-html-sanitizer (1.3.0)
404411
loofah (~> 2.3)
405412
rainbow (3.0.0)
@@ -553,6 +560,8 @@ GEM
553560
websocket (1.2.9)
554561
websocket-driver (0.7.3)
555562
websocket-extensions (>= 0.1.0)
563+
websocket-driver (0.7.3-java)
564+
websocket-extensions (>= 0.1.0)
556565
websocket-extensions (0.1.5)
557566
xpath (3.2.0)
558567
nokogiri (~> 1.8)
@@ -606,6 +615,7 @@ DEPENDENCIES
606615
racc (>= 1.4.6)
607616
rack-cache (~> 1.2)
608617
rails!
618+
rails-dom-testing!
609619
rake (>= 11.1)
610620
redcarpet (~> 3.2.3)
611621
redis (~> 4.0)

actionmailer/test/assert_select_email_test.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,29 @@ def test(options)
2020
end
2121

2222
#
23-
# Test assert_select_email
23+
# Test assert_dom_email
2424
#
2525

26-
def test_assert_select_email
26+
def test_assert_dom_email
2727
assert_raise ActiveSupport::TestCase::Assertion do
28-
assert_select_email { }
28+
assert_dom_email { }
2929
end
3030

3131
AssertSelectMailer.test("<div><p>foo</p><p>bar</p></div>").deliver_now
32-
assert_select_email do
33-
assert_select "div:root" do
34-
assert_select "p:first-child", "foo"
35-
assert_select "p:last-child", "bar"
32+
assert_dom_email do
33+
assert_dom "div:root" do
34+
assert_dom "p:first-child", "foo"
35+
assert_dom "p:last-child", "bar"
3636
end
3737
end
3838
end
3939

40-
def test_assert_select_email_multipart
40+
def test_assert_dom_email_multipart
4141
AssertMultipartSelectMailer.test(html: "<div><p>foo</p><p>bar</p></div>", text: "foo bar").deliver_now
42-
assert_select_email do
43-
assert_select "div:root" do
44-
assert_select "p:first-child", "foo"
45-
assert_select "p:last-child", "bar"
42+
assert_dom_email do
43+
assert_dom "div:root" do
44+
assert_dom "p:first-child", "foo"
45+
assert_dom "p:last-child", "bar"
4646
end
4747
end
4848
end

actionpack/CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1+
* Upgrade `rails-dom-testing` dependency, and rename all `assert_select` calls
2+
and documentation mentions with `assert_dom`.
3+
4+
*Sean Doyle*
5+
16
* Add `ActionController::Live#send_stream` that makes it more convenient to send generated streams:
27

38
```ruby
49
send_stream(filename: "subscribers.csv") do |stream|
510
stream.write "email_address,updated_at\n"
6-
11+
712
@subscribers.find_each do |subscriber|
813
stream.write "#{subscriber.email_address},#{subscriber.updated_at}\n"
914
end
1015
end
1116
```
12-
17+
1318
*DHH*
1419

1520
* `ActionDispatch::Request#content_type` now returned Content-Type header as it is.

actionpack/lib/action_dispatch/testing/integration.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ def method_missing(method, *args, &block)
532532
# https!(false)
533533
# get "/articles/all"
534534
# assert_response :success
535-
# assert_select 'h1', 'Articles'
535+
# assert_dom 'h1', 'Articles'
536536
# end
537537
# end
538538
#
@@ -571,7 +571,7 @@ def method_missing(method, *args, &block)
571571
# def browses_site
572572
# get "/products/all"
573573
# assert_response :success
574-
# assert_select 'h1', 'Products'
574+
# assert_dom 'h1', 'Products'
575575
# end
576576
# end
577577
#

actionpack/test/controller/caching_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,17 +443,17 @@ def test_collection_fetches_cached_views
443443
def test_preserves_order_when_reading_from_cache_plus_rendering
444444
get :index, params: { id: 2 }
445445
assert_equal 1, @controller.partial_rendered_times
446-
assert_select ":root", "david, 2"
446+
assert_dom ":root", "david, 2"
447447

448448
get :index_ordered
449449
assert_equal 3, @controller.partial_rendered_times
450-
assert_select ":root", "david, 1\n david, 2\n david, 3"
450+
assert_dom ":root", "david, 1\n david, 2\n david, 3"
451451
end
452452

453453
def test_explicit_render_call_with_options
454454
get :index_explicit_render_in_controller
455455

456-
assert_select ":root", "david, 1"
456+
assert_dom ":root", "david, 1"
457457
end
458458

459459
def test_caching_works_with_beginning_comment

actionpack/test/controller/request_forgery_protection_test.rb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def test_should_render_form_with_token_tag
192192
assert_not_blocked do
193193
get :index
194194
end
195-
assert_select "form>input[name=?][value=?]", "custom_authenticity_token", @token
195+
assert_dom "form>input[name=?][value=?]", "custom_authenticity_token", @token
196196
end
197197
end
198198

@@ -201,7 +201,7 @@ def test_should_render_button_to_with_token_tag
201201
assert_not_blocked do
202202
get :show_button
203203
end
204-
assert_select "form>input[name=?][value=?]", "custom_authenticity_token", @token
204+
assert_dom "form>input[name=?][value=?]", "custom_authenticity_token", @token
205205
end
206206
end
207207

@@ -232,7 +232,7 @@ def test_should_render_form_with_token_tag_if_remote_and_external_authenticity_t
232232
assert_not_blocked do
233233
get :form_for_remote_with_external_token
234234
end
235-
assert_select "form>input[name=?][value=?]", "custom_authenticity_token", "external_token"
235+
assert_dom "form>input[name=?][value=?]", "custom_authenticity_token", "external_token"
236236
ensure
237237
ActionView::Helpers::FormTagHelper.embed_authenticity_token_in_remote_forms = original
238238
end
@@ -242,15 +242,15 @@ def test_should_render_form_with_token_tag_if_remote_and_external_authenticity_t
242242
assert_not_blocked do
243243
get :form_for_remote_with_external_token
244244
end
245-
assert_select "form>input[name=?][value=?]", "custom_authenticity_token", "external_token"
245+
assert_dom "form>input[name=?][value=?]", "custom_authenticity_token", "external_token"
246246
end
247247

248248
def test_should_render_form_with_token_tag_if_remote_and_authenticity_token_requested
249249
@controller.stub :form_authenticity_token, @token do
250250
assert_not_blocked do
251251
get :form_for_remote_with_token
252252
end
253-
assert_select "form>input[name=?][value=?]", "custom_authenticity_token", @token
253+
assert_dom "form>input[name=?][value=?]", "custom_authenticity_token", @token
254254
end
255255
end
256256

@@ -259,7 +259,7 @@ def test_should_render_form_with_token_tag_with_authenticity_token_requested
259259
assert_not_blocked do
260260
get :form_for_with_token
261261
end
262-
assert_select "form>input[name=?][value=?]", "custom_authenticity_token", @token
262+
assert_dom "form>input[name=?][value=?]", "custom_authenticity_token", @token
263263
end
264264
end
265265

@@ -290,7 +290,7 @@ def test_should_render_form_with_with_token_tag_if_remote_and_external_authentic
290290
assert_not_blocked do
291291
get :form_with_remote_with_external_token
292292
end
293-
assert_select "form>input[name=?][value=?]", "custom_authenticity_token", "external_token"
293+
assert_dom "form>input[name=?][value=?]", "custom_authenticity_token", "external_token"
294294
ensure
295295
ActionView::Helpers::FormTagHelper.embed_authenticity_token_in_remote_forms = original
296296
end
@@ -300,15 +300,15 @@ def test_should_render_form_with_with_token_tag_if_remote_and_external_authentic
300300
assert_not_blocked do
301301
get :form_with_remote_with_external_token
302302
end
303-
assert_select "form>input[name=?][value=?]", "custom_authenticity_token", "external_token"
303+
assert_dom "form>input[name=?][value=?]", "custom_authenticity_token", "external_token"
304304
end
305305

306306
def test_should_render_form_with_with_token_tag_if_remote_and_authenticity_token_requested
307307
@controller.stub :form_authenticity_token, @token do
308308
assert_not_blocked do
309309
get :form_with_remote_with_token
310310
end
311-
assert_select "form>input[name=?][value=?]", "custom_authenticity_token", @token
311+
assert_dom "form>input[name=?][value=?]", "custom_authenticity_token", @token
312312
end
313313
end
314314

@@ -317,7 +317,7 @@ def test_should_render_form_with_with_token_tag_with_authenticity_token_requeste
317317
assert_not_blocked do
318318
get :form_with_local_with_token
319319
end
320-
assert_select "form>input[name=?][value=?]", "custom_authenticity_token", @token
320+
assert_dom "form>input[name=?][value=?]", "custom_authenticity_token", @token
321321
end
322322
end
323323

@@ -331,7 +331,7 @@ def test_should_render_form_with_with_token_tag_if_remote_and_embedding_token_is
331331
get :form_with_remote
332332
end
333333
end
334-
assert_select "form>input[name=?][value=?]", "custom_authenticity_token", @token
334+
assert_dom "form>input[name=?][value=?]", "custom_authenticity_token", @token
335335
ensure
336336
ActionView::Helpers::FormTagHelper.embed_authenticity_token_in_remote_forms = original
337337
end
@@ -663,8 +663,8 @@ class RequestForgeryProtectionControllerUsingResetSessionTest < ActionController
663663
test "should emit a csrf-param meta tag and a csrf-token meta tag" do
664664
@controller.stub :form_authenticity_token, @token + "<=?" do
665665
get :meta
666-
assert_select "meta[name=?][content=?]", "csrf-param", "custom_authenticity_token"
667-
assert_select "meta[name=?]", "csrf-token"
666+
assert_dom "meta[name=?][content=?]", "csrf-param", "custom_authenticity_token"
667+
assert_dom "meta[name=?]", "csrf-token"
668668
regexp = "#{@token}&lt;=\?"
669669
assert_match(/#{regexp}/, @response.body)
670670
end
@@ -753,14 +753,14 @@ def setup
753753
def test_should_not_render_form_with_token_tag
754754
SecureRandom.stub :urlsafe_base64, @token do
755755
get :index
756-
assert_select "form>div>input[name=?][value=?]", "authenticity_token", @token, false
756+
assert_dom "form>div>input[name=?][value=?]", "authenticity_token", @token, false
757757
end
758758
end
759759

760760
def test_should_not_render_button_to_with_token_tag
761761
SecureRandom.stub :urlsafe_base64, @token do
762762
get :show_button
763-
assert_select "form>div>input[name=?][value=?]", "authenticity_token", @token, false
763+
assert_dom "form>div>input[name=?][value=?]", "authenticity_token", @token, false
764764
end
765765
end
766766

@@ -1063,7 +1063,7 @@ def test_method_is_case_insensitive
10631063

10641064
private
10651065
def assert_presence_and_fetch_form_csrf_token
1066-
assert_select 'input[name="custom_authenticity_token"]' do |input|
1066+
assert_dom 'input[name="custom_authenticity_token"]' do |input|
10671067
form_csrf_token = input.first["value"]
10681068
assert_not_nil form_csrf_token
10691069
return form_csrf_token

actionpack/test/controller/test_case_test.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,17 +200,17 @@ def default_url_options
200200
end
201201
end
202202

203-
def test_assert_select_without_body
203+
def test_assert_dom_without_body
204204
get :test_without_body
205205

206-
assert_select "body", 0
207-
assert_select "div.foo"
206+
assert_dom "body", 0
207+
assert_dom "div.foo"
208208
end
209209

210-
def test_assert_select_with_body
210+
def test_assert_dom_with_body
211211
get :test_with_body
212212

213-
assert_select "body.foo"
213+
assert_dom "body.foo"
214214
end
215215

216216
def test_url_options_reset
@@ -407,17 +407,17 @@ def test_should_impose_childless_html_tags_in_html
407407
if defined?(JRUBY_VERSION)
408408
# https://github.com/sparklemotion/nokogiri/issues/1653
409409
# HTML parser "fixes" "broken" markup in slightly different ways
410-
assert_select "root > map > area + p"
410+
assert_dom "root > map > area + p"
411411
else
412-
assert_select "root > area + p"
412+
assert_dom "root > area + p"
413413
end
414414
end
415415

416416
def test_should_not_impose_childless_html_tags_in_xml
417417
process :test_xml_output, params: { response_as: "application/xml" }
418418

419419
# <area> is not special, so the <p> is its child
420-
assert_select "root > area > p"
420+
assert_dom "root > area > p"
421421
end
422422

423423
def test_assert_generates

0 commit comments

Comments
 (0)