1

を実行した後でも、次のエラーが表示されますrake db:test:prepare。私はRails 4.0を実行しています。

1) Core::PostsController GET index assigns all posts as @posts
     Failure/Error: post = Post.create! valid_attributes
     ActiveRecord::StatementInvalid:
       Could not find table 'core_posts'
     # ./spec/controllers/core/posts_controller_spec.rb:36:in `block (3 levels) in <module:Core>'

このテストをエンジン内で実行しているので、何か関連があるのでしょうか? 私のテストは次のようになります。

module Core
  describe PostsController do

    # This should return the minimal set of attributes required to create a valid
    # Post. As you add validations to Post, be sure to
    # adjust the attributes here as well.
    let(:valid_attributes) { {  } }

    # This should return the minimal set of values that should be in the session
    # in order to pass any filters (e.g. authentication) defined in
    # PostsController. Be sure to keep this updated too.
    let(:valid_session) { {} }

    describe "GET index" do
      it "assigns all posts as @posts" do
        post = Post.create! valid_attributes
        get :index, {}, valid_session
        assigns(:posts).should eq([post])
      end
    end


  end
end

何か案は?ありがとう!

4

2 に答える 2

0

テスト DB を再作成してみてください

rbenv なし

RAILS_ENV=test rake db:drop
RAILS_ENV=test rake db:create
RAILS_ENV=test rake db:test:prepare

rbenvで

RAILS_ENV=test bundle exec rake db:drop
RAILS_ENV=test bundle exec rake db:create
RAILS_ENV=test bundle exec rake db:test:prepare
于 2013-08-02T11:04:41.773 に答える