在rspec中<top(required)=“”>是什么意思?</top>

时间:2013-04-29 21:30:11

标签: 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
      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

rspec的意思是什么,可能是什么问题?

1 个答案:

答案 0 :(得分:0)

主机是CentOS5,包含的SQLite版本很旧,不适用于sqlite3 gem。 所以我不得不将捆绑包配置为使用更新的sqlite版本。

bundle config build.sqlite3 \
  --with-sqlite3-include=/package/host/localhost/sqlite-3/include \
  --with-sqlite3-lib=/package/host/localhost/sqlite-3/lib

后跟bundle install

问题解决了。