Ruby on Rails Tutorial (5)
ええと、8.4 の RSpec integration tests で挙動不審だった模様。bundle exec の出力を lv に渡して確認してみたら、なんとなく処理てきには正しいみたいなんですが、試験にパスしない風の出力なのかなぁ。
例えば最初の試験だと
1) Users signup failure should not make a new user Failure/Error: response.should have_selector("div#error_explanation") expected following output to contain a <div#error_explanation/> tag:
とか次の試験だと
2) Users signup success should make a new user Failure/Error: response.should have_selector("div.flash.success", expected following output to contain a <div.flash.success>Welcome</div.flash.success> tag:
とのこと。とりあえず、ということで app/views/layouts/application.html.erb を確認したところ、以下が盛り込まれていないことを確認。
<%= render 'layouts/header' %> <section class="round"> <% flash.each do |key, value| %> <div class="flash <%= key %>"><%= value %></div> <% end %> <%= yield %> </section>
むむ。盛り込んだら試験に失敗は一つになりました。("div#error_explanation") なソレが失敗している模様。てか、盛り込み漏れってどーゆーことだよorz
もう一つの異常系についても
- app/views/users/new.html.erb に盛り込み漏れ
- shared/error_messages 盛り込み漏れ
- app/views に shared ディレクトリ作って
- app/views/sharec/_error_messages.html.erb 作成
を盛り込んで試験リトライしたら失敗が増えたw
1) LayoutLinks should have a signup page at '/signup' Failure/Error: get '/signup' (中略 2) Users signup failure should not make a new user Failure/Error: visit signup_path (中略 3) Users signup success should make a new user Failure/Error: visit signup_path
と思ったら _error_messages.html.erb が微妙なのかどうなのか。あ、最後の end が
<% end %>
じゃなくて
<% end >%
ってなってた。修正してリトライしたら green でした。
$ bundle exec rspec spec/requests/ ....... Finished in 2.07 seconds 7 examples, 0 failures $
読んでないのがモロバレなので明日の朝練は Chapter 8 をログを見つつ再読の方向です。今からも一応確認の方向で。。