2013-07-14 23 views
0

這是我requests/profiles_pages_spec.rb未定義的current_path方法或變量豚

require 'spec_helper' 

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) } 
    current_path.should == user_path(user) 
end 
end 
end 

我有錯誤:

規格/請求/ profile_pages_spec.rb:40:塊(3級)中:未定義的局部變量或方法`current_path'爲#(NameError)

爲什麼我不能使用這種方法?

我用寶石「水豚」,「1.1.2」和 寶石「RSpec的護欄」,「2.11.0」

回答

0

你不是在它塊時。

describe "submitting to the update action" do 
    before { put profile_path(profile) } 
    it "redirects to show path" do 
    current_path.should == user_path(user) 
    end 
end 
+0

是的,謝謝,我明白了,這是因爲'subject {page}' –

+0

btw,你也可以使用指定塊 – apneadiving

相關問題