テストとレールは初めてですが、TDDプロセスを適切にダウンさせようとしています。
has_many :through リレーションシップをテストするために何らかのパラダイムを使用するかどうか疑問に思っていましたか? (または、一般的には has_many だけだと思います)。
たとえば、私のモデル仕様では、関連メソッドの関係の両端をチェックする簡単なテストを確実に書いていることがわかりました。
すなわち:
require 'spec_helper'
describe Post do
before(:each) do
@attr = { :subject => "f00 Post Subject", :content => "8ar Post Body Content" }
end
describe "validations" do
...
end
describe "categorized posts" do
before(:each) do
@post = Post.create!(@attr)
end
it "should have a categories method" do
@post.should respond_to(:categories)
end
end
end
次に、カテゴリ仕様で逆テストを行い、@category.posts をチェックします。
他に何が欠けていますか?ありがとう!!