items_controllers.rb
it "Cannot register if the zip code is empty" do
@user_item.postal_code = nil
binding.pry
@user_item.valid?
expect(@user_item.errors.full_messages).to include("Postal code can't be blank")
end
When I tried to get the error message in the terminal with the above description in the controller, the following result was obtained.
console
[1] pry(#<RSpec::ExampleGroups::UserItem::Nested::Nested_2>)> @user_item.errors.full_messages
=> []
why? ?? I thought that there was a validation problem if there was no error message, but the cause was not there.
The location of binding.pry was incorrect. or I made a mistake in the order from applying binding.pry to arriving at the error message.
When binding.pry is applied, the movement of the PC stops at that point, but when moving from there on the console, the order was important. Give me an error message unnecessarily! Even so, the computer doesn't work. First of all, if you apply binding.pry to the above location,
console
@item.valid?
I had to write on the console. And for the first time if the return value is false
console
@item.errors.full_messages
By describing, an error message will be returned.
When binding.pry is applied, the console will fulfill your wishes if you proceed while checking the order in the same way as with a normal controller, instead of asking for the Paramus value or error message unnecessarily.