【发布时间】:2013-06-26 11:45:24
【问题描述】:
require 'spec_helper'
describe StudentsController do
fixtures :all
context "#profile" do
let(:school) { Factory.create(:school_2) }
before do
session[:email] = user.email
session[:user_id] = user.id
end
it "should assign the user to @user" do
User.stub(:find).with(user.id).and_return(user)
get :profile
assigns[:user].should eql(user)
end
end
end
在后挂钩中发生错误:
NoMethodError: undefined method `original_path_set' for nil:NilClass
occurred at /home/qbadmin/.rvm/gems/ruby-1.9.3-p194/gems/rspec-rails-2.13.1/lib/rspec/rails/view_rendering.rb:121:in `block (2 levels) in <module:ViewRendering>'
这是我从命令行运行rspec spec 时遇到的错误。谁能帮我找出问题所在?
我在 Gemfile 中指定的 RSpec 版本是:
gem 'rspec', '~> 2.13',
gem 'rspec-rails', '~> 2.13'
提前致谢。
【问题讨论】:
-
你能提供一些代码吗?
-
当我在终端中给出命令“rspec spec”时,它会产生类似上面的错误。它会在整个规范中连续显示。检查错误路径时,存在名为 original_path_set 的方法。但不知道如何解决此问题。
-
能否提供您的规范代码
-
`require 'spec_helper' describe StudentsController do fixtures :all context "#profile" do let(:school) { Factory.create(:school_1) } before do session[:email] = user.email session[:user_id] = user.id 结束它“应该将用户分配给@user”做 User.stub(:find).with(user.id).and_return(user) get :profile assigns[:user].should eql(user) end end end'
-
请更新您的问题以包含您刚刚提供的代码,最后请使用 markdown synax 缩进您的代码 :)
标签: ruby-on-rails rspec