0
我正在從Edx.org獲得SaaS的HW4。我在運行情景2和3的黃瓜時遇到了問題。當我嘗試使用Web應用程序時,它在這兩種情況下效果很好。但運行黃瓜,我得到這樣的輸出:SaaS Hw4的問題
Scenario: find movie with same director # features/search_movies_director.feature:22
Deprecated: please use #source_tags instead.
Given I am on the details page for "Star Wars" # features/step_definitions/web_steps.rb:44
When I follow "Find Movies With Same Director" # features/step_definitions/web_steps.rb:56
Then I should be on the Similar Movies page for "Star Wars" # features/step_definitions/web_steps.rb:230
No route matches {:action=>"director", :controller=>"movies"} (ActionController::RoutingError)
./features/support/paths.rb:20:in `path_to'
./features/step_definitions/web_steps.rb:233:in `/^(?:|I)should be on (.+)$/'
features/search_movies_director.feature:25:in `Then I should be on the Similar Movies page for "Star Wars"'
And I should see "THX-1138" # features/step_definitions/web_steps.rb:105
But I should not see "Blade Runner" # features/step_definitions/web_steps.rb:123
Scenario: can't find similar movies if we don't know director (sad path) # features/search_movies_director.feature:29
Deprecated: please use #source_tags instead.
Given I am on the details page for "Alien" # features/step_definitions/web_steps.rb:44
Then I should not see "Ridley Scott" # features/step_definitions/web_steps.rb:123
When I follow "Find Movies With Same Director" # features/step_definitions/web_steps.rb:56
Then I should be on the home page # features/step_definitions/web_steps.rb:230
expected: "/movies"
got: "/movies/3/director" (using ==) (RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/web_steps.rb:233:in `/^(?:|I)should be on (.+)$/'
features/search_movies_director.feature:33:in `Then I should be on the home page'
And I should see "'Alien' has no director info" # features/step_definitions/web_steps.rb:105
在這兩種情況下,當我手動執行此情況下,該行爲是正確的。問題是什麼?
感謝
當我執行 '耙路線',我得到:
director_movie GET /movies/:id/director(.:format) {:action=>"director", :controller=>"movies"}
movies GET /movies(.:format) {:action=>"index", :controller=>"movies"}
POST /movies(.:format) {:action=>"create", :controller=>"movies"}
new_movie GET /movies/new(.:format) {:action=>"new", :controller=>"movies"}
edit_movie GET /movies/:id/edit(.:format) {:action=>"edit", :controller=>"movies"}
movie GET /movies/:id(.:format) {:action=>"show", :controller=>"movies"}
PUT /movies/:id(.:format) {:action=>"update", :controller=>"movies"}
DELETE /movies/:id(.:format) {:action=>"destroy", :controller=>"movies"}
在這裏,我可以看到路線「director_movie GET /movies/:id/director(.:format){ :action =>「導演」,:控制器=>「電影」}「,所以我不明白爲什麼第一個場景失敗。
在第二個,它預計「/電影」,並得到「/電影/ 3 /導演」。這裏是從控制器的代碼段:
def director
mov = Movie.find(params[:id])
dir = mov.director
if (dir == nil)
flash[:notice] = "'#{mov.title}' has no director info"
redirect_to movies_path
else
@movies = Movie.find_all_by_director(dir)
end
end
但是,當我手動模擬相同的步驟,我看到的提示信息,並得到重定向到「/電影」 ...爲什麼黃瓜沒有得到同樣的?
對不起,我的英語......謝謝!
什麼產生輸出? – Ben 2013-02-15 22:10:31
該輸出來自測試工具cucumber。 – user2076905 2013-02-15 23:32:20