Exercise 2: His suggested template for checking error messages associated with signing up on a form are the last two assert_selects below:
require 'test_helper'
class UsersSignupTest < ActionDispatch::IntegrationTest
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 cannot figure out what needs to replace what he has within the brackets. The custom CSS has form sections like this:
#error_explanation {
color: red;
ul {
color: red;
margin: 0 0 30px 0;
}
}
.field_with_errors {
@extend .has-error;
.form-control {
color: $state-danger-text;
}
}
add them as he gave instructions
assert_select 'div#<CSS id for error explanation>'
assert_select 'div.<CSS class for field with error>'
will be
assert_select 'div#error_explanation'
assert_select 'div.field_with_errors'
assert_select 'div#error_explanation'
assert_select 'div.field_with_errors'
The tutorial wanted me to replace the example with above code. I did not understand that, but at last found the answer.
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.