简体   繁体   中英

Depretieation Warning for CSS in Michael Hartel's Ruby on Rails tutorial 7.7

I keep getting this error about the CSS in section 7.7:

DEPRECATION WARNING: The assertion was not run because of an invalid css 
unexpected '#' after '[#<Nokogiri::CSS::Node:0x000000076e23f8 @type=:ELEMENT_NAME, 
@value=["div"]>]' (called from block in <class:UsersSignupTest> at   
/home/ubuntu/workspace/sample-app/test/integration/users_signup_test.rb:14)

DEPRECATION WARNING: The assertion was not run because of an invalid css selector.
unexpected '<' after '.' (called from block in <class:UsersSignupTest> at 
/home/ubuntu/workspace/sample-app/test/integration/users_signup_test.rb:15)

The users_signup_test.rb test is below with the specific problem mentioned in the Deprecation Warning in the assert_selects (which are lines 14 and 15 in my code):

 test "invalid signup information" do
get signup_path
assert_no_difference 'User.count' do
post users_path, user: { name: "",
                        email: "user@invalid",
                        password: "foo",
                        password_confirmation: "bar" }
  end
  assert_template 'users/new'
  assert_select 'div#<CSS id for error explanation>'
  assert_select 'div.<CSS class for field with error>'
end

I've checked this code against the book and it seems to be what he has, it just bothers me because the error shows up on every test I run.

You are supposed to replace the <CSS id for error explanation> with the id of the box you're showing the error explanation in -- same with the class. What you've copied is a suggested template, not runnable code

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM