Search code examples
ruby-on-rails-3rspecruby-on-rails-3.2rspec-rails

What does mean <top (required)> in 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

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

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


Solution

  • 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
    

    Followed by a bundle install

    Problem solved.