0
我使用RSpec測試,我還在學習,我想我在正確的道路......但是當我測試我的RSpec的文件,我得到這個錯誤:故障/錯誤:預期{click_button提交}
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=> "[email protected]"
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
感謝您的關注
ps:如果您在調查時遇到問題,請發佈rspec中的實際故障(進一步在輸出中) - 另一件我注意到的事情:這是集成還是控制器測試? (它位於哪裏?) - 從文件我會說一個集成測試,但它說描述UsersController。請參閱http://stackoverflow.com/questions/5932605/capybara-rspec-only-sees-blank-pages-in-controller-specs-爲了討論。 – bento 2012-07-26 14:31:32
感謝您的回答,閱讀您的文章,我猜測規範不夠充分,因爲實施工作 – Asantoya17 2012-07-26 14:44:33
可以發佈失敗規範的完整輸出嗎? – bento 2012-07-26 14:50:03