Ruby on rails 3 什么意思<;顶部(必需)>;在rspec?

Ruby on rails 3 什么意思<;顶部(必需)>;在rspec?,ruby-on-rails-3,rspec,ruby-on-rails-3.2,rspec-rails,Ruby On Rails 3,Rspec,Ruby On Rails 3.2,Rspec Rails,我有一些rspec测试。比如说 require 'spec_helper' describe UsersController do before (:each) do @user = FactoryGirl.create(:user) sign_in @user end describe "GET 'show'" do it "should be successful" do get :show, :id => @user.id

我有一些rspec测试。比如说

require 'spec_helper'

describe UsersController do

  before (:each) do
    @user = FactoryGirl.create(:user)
    sign_in @user
  end

  describe "GET 'show'" do

    it "should be successful" do
      get :show, :id => @user.id
      response.should be_success
    end

    it "should find the right user" do
      get :show, :id => @user.id
      assigns(:user).should == @user
    end

  end

end
当我运行rspec时,我得到一些错误

Failures:

  1) UsersController GET 'show' should be successful
     Failure/Error: @user = FactoryGirl.create(:user)
     ActiveRecord::StatementInvalid:
       SQLite3::SQLException: near "SAVEPOINT": syntax error: SAVEPOINT active_record_1
     # ./spec/controllers/users_controller_spec.rb:6:in `block (2 levels) in <top (required)>'

  2) UsersController GET 'show' should find the right user
     Failure/Error: @user = FactoryGirl.create(:user)
     ActiveRecord::StatementInvalid:
       SQLite3::SQLException: near "SAVEPOINT": syntax error: SAVEPOINT active_record_1
     # ./spec/controllers/users_controller_spec.rb:6:in `block (2 levels) in <top (required)>'

rspec ./spec/controllers/users_controller_spec.rb:12 # UsersController GET 'show' should be successful
rspec ./spec/controllers/users_controller_spec.rb:17 # UsersController GET 'show' should find the right user
故障:
1) UsersController获取“show”应成功
失败/错误:@user=FactoryGirl.create(:user)
ActiveRecord::语句无效:
SQLite3::SQLException:靠近“保存点”:语法错误:保存点活动\u记录\u 1
#./spec/controllers/users\u controller\u spec.rb:6:in'block(2级)in'
2) UsersController获取“show”应找到正确的用户
失败/错误:@user=FactoryGirl.create(:user)
ActiveRecord::语句无效:
SQLite3::SQLException:靠近“保存点”:语法错误:保存点活动\u记录\u 1
#./spec/controllers/users\u controller\u spec.rb:6:in'block(2级)in'
rspec./spec/controllers/users_controller_spec.rb:12#users controller获取“show”应成功
rspec./spec/controllers/users_controller_spec.rb:17#users控制器获取“show”应该找到正确的用户

这意味着什么?rspec可能有什么问题?

主机是CentOS5,附带的SQLite版本很旧,不能与sqlite3 gem一起使用。 因此,我必须配置bundler以使用较新安装的sqlite版本

bundle config build.sqlite3 \
  --with-sqlite3-include=/package/host/localhost/sqlite-3/include \
  --with-sqlite3-lib=/package/host/localhost/sqlite-3/lib
然后是
捆绑安装

问题已解决。

请查看此答案: