我對RSpec很新。我正在嘗試爲Rails應用程序做一個基本的控制器測試。我想檢查一下,當我使用PostsController的「創建」操作時,用戶被重定向到posts路徑。這是我目前的測試。RSpec控制器測試錯誤
describe "POST #create" do
it "returns http success" do
post :create, {'post' => { :title => "My first post", :author => 'Jack Seabolt'} }
expect(response). to have_http_status(:success)
end
it "redirects to 'index' template" do
post :create , {'post' => {:title => "my first post", :author => 'Jack Seabolt'} }
expect(response) redirect_to(posts_path)
end
end
此代碼導致此錯誤:
/Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1435:in `load':
/Users/johnseabolt/Desktop/projects/tdd/spec/controllers/posts_controller_spec.rb:49: syntax error, unexpected tIDENTIFIER, expecting keyword_end (SyntaxError)
expect(response) redirect_to(posts_path)
^
我試圖將只是 '帖子'。我試過'索引'。沒有工作。如果有人能指引我正確的方向,我將不勝感激。謝謝。
與尋找解決任何運氣爲t他? –