<top (required)> 是什么意思?在 rspec 中? [英] What does mean <top (required)> in rspec?

查看:67
本文介绍了<top (required)> 是什么意思?在 rspec 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些 rspec 测试.例如

I have some rspec test. For example

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 时出现一些错误

When I run the rspec i get some errors

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 是什么意思,可能有什么问题?

What does the mean and what could be the problem with that rspec?

推荐答案

主机是 CentOS5,包含的 SQLite 版本很旧,不能与 sqlite3 gem 一起使用.所以我不得不配置捆绑器以使用较新安装的 sqlite 版本.

Host is CentOS5 and the included SQLite version is old and dont work with the sqlite3 gem. So i had to config the bundler to use a newer installed sqlite version.

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

接着是捆绑安装

问题解决了.

这篇关于&lt;top (required)&gt; 是什么意思?在 rspec 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆