我用 rspec 测试,我还在学习,我想我是在正确的方式......但是当我测试我的 rspec 文件时,我得到了这个错误:
Failures:
1) UsersController signup with valid information should create a user
Failure/Error: expect { click_button submit }.to change(User, :count).by(1)
count should have been changed by 1, but was changed by 0
# ./spec/controllers/user_controller_spec.rb:31
Finished in 1.16 seconds
2个例子,1个失败
我知道这意味着什么,但我不知道如何解决它,任何人都可以帮我解决这个问题...另外我把我的 rspec 文件
require 'spec_helper'
describe UsersController do
describe "signup" do
before { visit new_user_registration_path }
let(:submit) { "Sign up" }
describe "with invalid information" do
it "should not create a user" do
expect { click_button submit }.not_to change(User, :count)
end
end
describe "with valid information" do
before do
fill_in "Email", :with=> "user@example.com"
fill_in "Password", :with=> "foobar"
#fill_in "password_confirmation", :with=> "foobar"
end
(这是出现错误...下一行)
it "should create a user" do
expect { click_button submit }.to change(User, :count).by(1)
end
end
end
end
感谢您的关注