1

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'
3
  • I'm surprised it's not looking for table 'supercars'. Have you set the table name on your Supercar Model? Commented Nov 9, 2013 at 22:44
  • Shouldn't the factory call look like Factory.create(:supercar) - This looks like old FactoryGirl syntax. I'm used to seeing something more like @car = FactoryGirl.create(:supercar) Commented Nov 9, 2013 at 22:45
  • 1
    Make sure you have properly setup your test database:run rake db:test:clone after rake db:migrate Commented Nov 10, 2013 at 8:33

1 Answer 1

1

The solution is to run this command:

rake db:test:prepare

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.