2016-05-31 4 views
0

私のRSpecのテストが投げるエラー仕様で@controllerを設定すると、ActionView :: MissingTemplateエラーが発生するのはなぜですか?

ActionView::MissingTemplate:

例えばを開始しましたMissing template users/indexが募集中です./spec/controllers/users_controller_spec.rb

これらのテンプレートは間違いありません。

多くのデバッグの後、私は評判/ポイントシステムをテストしている別のコントローラ仕様に戻しました。評判が各種コントローラとアクションの間に印加されているので、私は次のように各スペック何かを設定しています:

#./spec/controllers/reputation_rules_spec.rb 
describe 'Reputation Rules', type: :controller do 
    describe "update user" do 
    before :each do 
     @controller = UsersController.new 
    end 
    it 'tests that reputation is adjusted' 
    end 
    describe "tests reptation on other controller/action combinations".... 
end 

私は@controller行をコメントアウトした場合、missing templateエラーが消え、もちろん評判の仕様は、失敗します。

なぜこの@controllerの影響を与えるテストが現在の仕様外ですか?

テスト後に何とか@controllerをリセットする必要がありますか、何か間違っていますか?

答えて

0

私は

#./spec/controllers/reputation_rules_spec.rb 
after :all do 
    @controller = nil 
end 

を追加することでこれを解決したが@controllerは、他のテスト

に永続化される理由はまだ不明です
関連する問題