ruby-digger
ruby-digger

Reputation: 128

RSpec error: test couldn't find table

I am trying to test this part of controller with Rspec:

@supercar = Supercar.find(params[:id])

Here is my controller spec to test the part mentioned above:

before (:each) do
  @supercar = Factory :supercar
end

describe "show" do

  it "assigns the requested supercar to the @supercar" do
    get :show, :id => @supercar.id
    assigns(:supercar).should == @supercar
  end
...

However, I've tried to run command rake db:migrate, but still getting this error:

Failure/Error: @supercar = Factory :supercar
     ActiveRecord::StatementInvalid:
       Could not find table 'supercar'

Upvotes: 1

Views: 413

Answers (1)

user3749465
user3749465

Reputation: 32

The solution is to run this command:

rake db:test:prepare

It is preparing the test database, by loading the scheme there.

Upvotes: 1

Related Questions