我有以下控制器 RSpec 测试,但是当我尝试执行以下代码时,它应该可以工作:
require 'spec_helper'
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe UsersController do
include Devise::TestHelpers #Include devise test helpers
render_views # Render devise views
describe "GET 'show'"
before(:each) do
@user = User.find(params[:id])
@attr = {:initials => 'EU', :name => 'Example', :full_name => 'Example User',
:email => 'user@example.com', :password => 'password', :password_confirmation => 'password'
#@attr = User.all
}
end
it 'should be successful when showing OWN details' do
get :show, :id => @attr
response.should be_success
end
it 'should find the correct user' do
get :show, :id => @attr
assigns(@attr).should == @attr
end
end
但是我得到以下输出:Undefined locacl variable or method 'params' for RSPRC
我相信这个设置应该是正确的。