简体   繁体   English

current_path未定义的方法或变量水豚

[英]current_path undefined method or variable capybara

It's my requests/profiles_pages_spec.rb : 这是我的requests/profiles_pages_spec.rb

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

I have error: 我有错误:

spec/requests/profile_pages_spec.rb:40:in block (3 levels) in : undefined local variable or method `current_path' for # (NameError) spec / requests / profile_pages_spec.rb:40:in块(3级)中:#(NameError)的未定义局部变量或方法“ current_path”

Why I can't use this method? 为什么我不能使用这种方法?

I use gem 'capybara', '1.1.2' and gem 'rspec-rails', '2.11.0' 我使用gem'capybara','1.1.2'和gem'rspec-rails','2.11.0'

You're not working in a it block. 您不是在it区块中工作。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM