7. 5.2.1 Integration Tests spec/requests/layout_links_spec.rb に以下のテストを追加 describe " GET 'home' " do it " should be successful " do get ' home ' response .should be_success end end
8. 5.2.1 Integration Tests 自動でテストが実行されない場合 .autotest に追加 Mac OS X の場合 Autotest . add_hook :initialize do | autotest | autotest . add_mapping( /^spec\/requests\/.*_spec\.rb$/ ) do autotest . files_matching( /^spec\/requests\/.*_spec\.rb$/ ) end end
9. 5.2.1 Integration Tests Ubuntu か Linux の場合 Autotest . add_hook :initialize do | autotest| autotest . add_mapping( %r%^spec/(requests)/.*rb$% ) do | filename, _ | filename end end
16. 6.1.1 Database Migration User コントローラ作成 (new アクション付き ) User モデル作成 (name と email を持っている ) $ rails g controller Users new $ rails g model User name:string email:string
18. 6.1.2 The Model File Model Annotation annotate という gem を入れる Gemfile に’ annotate’ 追加 ※ 注意 :git=> 以下を追加しないと 3.1 系で動かない https://github.com/ctran/annotate_models/issues/28 group :development do gem ' rspec-rails ' gem ' annotate ' , :git => ' git://github.com/ctran/annotate_models.git ' end
19. 6.1.2 The Model File 実行結果 $ bundle exec annotate --position before # == Schema Information # # Table name: users # # id :integer not null, primary key # name :string(255) # email :string(255) # created_at :datetime # updated_at :datetime # class User < ActiveRecord :: Base end 追加されている
20. 6.1.3 Creating user objects --sandbox で DB には変更を加えない -f オプションで常に最新のログを見れる $ rails console --sandbox $ tail –f log/development.log
21. 6.2 User Validations TDD のため、 development DB の 構造 を test DB に反映させる $ bundle exec rake db:test:prepare
22. 6.2.3 Format Validation email 等のバリデーション用正規表現 Rubular(http://rubular.com/) 正規表現の入力 ->マッチするか確認