せずに私はこのようなshoulda楽しく使ってきた「必要があります」:さshouldaを使用してブロック
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
私にははっきりしていないもの:
context "test world" do
setup do
@world = ...
end
should "be spinning" do
assert_equal "spinning", @world.movement
end
... and so on
end
私はこの変化を理解する上でヒントを必要とします様々な「所持すべき(:ユーザ)」 などが動作しています。言い換えれば、彼らがPostのインスタンス上で動作していることがかなり明確に表示されますが、 はそれを判断していますか? 「should xxx」行の主題は何ですか?
これは初心者の質問であることを知っていますので、どんなポインタでも大丈夫です!
ありがとう:そして、あなたは、Active Recordのための具体的なシングルラインアサーション興味がある場合は、アクティブレコードのマッチャーを見てみましょう。非常に役立ちます。 – pitosalas