我在我以前的問題有問題,我幫助,但現在我已經採取新的。 我正在與RSpec和水豚進行集成測試。與水豚錯誤的重定向
這個我profiles_controllers.rb:
before_filter :authenticate_user!
def update
@profile = current_user.profile
if @profile.update_attributes(params[:profile])
flash[:success] = "Профиль обновлен!"
redirect_to user_path(current_user)
else
render 'edit'
end
end
這是我的測試文件:
describe "ProfilePages" do
subject { page }
describe "edit" do
let(:user) { FactoryGirl.create(:user) }
let(:profile) { FactoryGirl.create(:profile, user: user) }
before do
login user
visit edit_profile_path(profile)
end
it { should have_selector('h2', text: 'Заполните информацию о себе') }
describe "change information" do
let(:new_city) { "Ulan-Bator" }
let(:new_phone) { 1232442 }
let(:new_gamelevel) { "M2" }
let(:new_aboutme) { "nfsfsdfds" }
let(:submit) { "Сохранить" }
before do
fill_in "Город", with: new_city
fill_in "Телефон", with: new_phone
select new_gamelevel, from: "Уровень игры"
fill_in "О себе", with: new_aboutme
click_button submit
end
specify { profile.reload.city.should == new_city }
specify { profile.reload.phone.should == new_phone }
specify { profile.reload.gamelevel.should == new_gamelevel }
specify { profile.reload.aboutme.should == new_aboutme }
end
describe "submitting to the update action" do
before { put profile_path(profile) }
specify { response.should redirect_to(user_path(user)) }
end
end
end
而且我有錯誤:
故障/錯誤:指定{response.should redirect_to的(user_path (用戶))} 預期的響應是重定向到http://www.example.com/users/1,但重定向到http://www.example.com/users/sign_in
我使用的設計和規格/支持已經登錄助手:
def login(user)
page.driver.post user_session_path, 'user[email]' => user.email, 'user[password]' => user.password
end
而且config.include Devise::TestHelpers, :type => :controller
在spec_helper.rb
我試圖使用區長幫手login_as,但具有同樣的錯誤。我怎麼理解這不是開始會議,我是對的?
感謝您的建議,但它不工作:'未定義的局部變量或方法的current_path'」爲#<類別:0x00000004810368>' –