【问题标题】:What does mean <top (required)> in rspec?rspec 中的 <top (required)> 是什么意思?
【发布时间】:2013-04-29 21:30:10
【问题描述】:

我有一些 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 是什么意思以及可能有什么问题?

【问题讨论】:

标签: ruby-on-rails-3 rspec ruby-on-rails-3.2 rspec-rails


【解决方案1】:

主机是 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

问题解决了。

【讨论】:

    猜你喜欢
    • 2011-09-13
    • 1970-01-01
    • 2015-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多