RSPEC을 사용하는 경우 분명히 '변경'이 있어야합니다. 여기에 두 가지 예는 부정적이고 긍정적 인 사람은 그래서 당신은 구문의 감각 할 수 있습니다 : 당신이 올바른 RSpec에와 assert_difference 보석을 사용하고있는 것 같습니다
RSpec.describe "UsersSignups", type: :request do
describe "signing up with invalid information" do
it "should not work and should go back to the signup form" do
get signup_path
expect do
post users_path, user: {
first_name: "",
last_name: "miki",
email: "[email protected]",
password: "buajaja",
password_confirmation: "juababa"
}
end.to_not change{ User.count }
expect(response).to render_template(:new)
expect(response.body).to include('errors')
end
end
describe "signing up with valid information" do
it "should work and should redirect to user's show view" do
get signup_path
expect do
post_via_redirect users_path, user: {
first_name: "Julito",
last_name: "Triculi",
email: "[email protected]",
password: "worldtriculi",
password_confirmation: "worldtriculi"
}
end.to change{ User.count }.from(0).to(1)
expect(response).to render_template(:show)
expect(flash[:success]).to_not be(nil)
end
end
를? 나는 그것을'it' 블록으로 감쌀 필요가 있다고 생각한다. –
나는 그것을 블록에 넣으려고하지만 여전히이 오류가있다. –