0

I'm going through the Rails Tutorial (using the cloud9 ide) (3rd Edition https://www.railstutorial.org/book/) and I'm running into something odd.

I've just finished chapter 7, and I'm just now noticing that some of my assertions from chapter 5 are not running because "The assertion was not run because of an invalid css selector."

Here's the contents of my test/integration/site_layout_test.rb

require 'test_helper'

class SiteLayoutTest < ActionDispatch::IntegrationTest
  test "layout links" do
    get root_path
    assert_template 'static_pages/home'
    assert_select "a[href=?", root_path, count: 2
    assert_select "a[href=?", help_path
    assert_select "a[href=?", about_path
    assert_select "a[href=?", contact_path
    assert_select "a[href=?", signup_path
  end
end

It seems to be a character for character match to the code found in https://github.com/mhartl/sample_app_3rd_edition/blob/master/test/integration/site_layout_test.rb

the errors that I'm getting are as follows

DEPRECATION WARNING: The assertion was not run because of an invalid css selector.=======                                           ] 66% Time: 00:00:00,  ETA: 00:00:00
unexpected '$' after '[:equal, "\"/\""]' (called from block in <class:SiteLayoutTest> at /home/ubuntu/workspace/sample_app/test/integration/site_layout_test.rb:7)
DEPRECATION WARNING: The assertion was not run because of an invalid css selector.
unexpected '$' after '[:equal, "\"/help\""]' (called from block in <class:SiteLayoutTest> at /home/ubuntu/workspace/sample_app/test/integration/site_layout_test.rb:8)
DEPRECATION WARNING: The assertion was not run because of an invalid css selector.
unexpected '$' after '[:equal, "\"/about\""]' (called from block in <class:SiteLayoutTest> at /home/ubuntu/workspace/sample_app/test/integration/site_layout_test.rb:9)
DEPRECATION WARNING: The assertion was not run because of an invalid css selector.
unexpected '$' after '[:equal, "\"/contact\""]' (called from block in <class:SiteLayoutTest> at /home/ubuntu/workspace/sample_app/test/integration/site_layout_test.rb:10)
DEPRECATION WARNING: The assertion was not run because of an invalid css selector.
unexpected '$' after '[:equal, "\"/signup\""]' (called from block in <class:SiteLayoutTest> at /home/ubuntu/workspace/sample_app/test/integration/site_layout_test.rb:11)

What I find really interesting is that if I delete all of the content from my stylesheets, I still get the same errors.

I have no clue as to where the term "about_path" (or any of the other path symbols) is picking up a $ char.

Am I missing something obvious, I can't find any references when I google the the warning text that has helps me track things back.

1 Answer 1

4

You are missing closing square brackets in your a[href] arguments. Your code should be as follows:

require 'test_helper'

class SiteLayoutTest < ActionDispatch::IntegrationTest
  test "layout links" do
    get root_path
    assert_template 'static_pages/home'
    assert_select "a[href=?]", root_path, count: 2
    assert_select "a[href=?]", help_path
    assert_select "a[href=?]", about_path
    assert_select "a[href=?]", contact_path
    assert_select "a[href=?]", signup_path
  end                      
end
1
  • Exactly my problem. I stared at that code for at least 15 minutes and believed I was doing a character by character comparison. Feb 3, 2015 at 5:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.