这是什么意思 在rspec的?(What does mean in rspec?)

2019-10-18 02:24发布

我有一些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的问题呢?

Answer 1:

主机是CentOS5和SQLite的包括版本是旧的,不与sqlite3的宝石工作。 因此,我不得不配置为使用新安装的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

问题解决了。



文章来源: What does mean in rspec?