私はこのように楽しくshouldaを使用しています:
context "test world" do
setup do
@world = ...
end
should "be spinning" do
assert_equal "spinning", @world.movement
end
... and so on
end
このバリエーションを理解するためのヒントが必要です。
class PostTest < Test::Unit::TestCase
should belong_to(:user)
should have_many(:tags).through(:taggings)
should validate_uniqueness_of(:title)
should validate_presence_of(:body).with_message(/wtf/)
should validate_presence_of(:title)
should validate_numericality_of(:user_id)
end
私にはわかりませんが、さまざまな「belong_to(:user)」などが何を操作しているのかがわかりません。言い換えれば、それらがPostのインスタンスで動作していることはかなり明らかですが、それを決定しているのは何ですか?'should xxx'行の主題は何ですか?
私はこれが初心者の質問であることを知っているので、どんなポインタも素晴らしいでしょう!