单元测试中 product.errors.invalid? 的用法
p 181
# product.rb
validates_presence_of :title

def test_invalid_with_empty+attributes
  product = Product.new
  assert !product.valid?
  assert product.errors.invalid?(:title)
end

p190
assert_match(pattern, string, message)
assert_not_match(pattern, string, message)
assert(/flower/i, user.town)

p192
仅测试,类中的一个方法
ruby test/functional/login_controller_test.rb -n test_index

p196
xmlhttprequest 的测试支持
xhr(:get, :add_to_cart, :id => 11)

p198
针对功能测试的辅助方法
1.
p198
tag = find_tag :tag => "form",
                    :attributes => {:action => "/store/add_to_cart/993"}
assert_equal "post", tag.attributes["method"]

2.
p199
assert_select "div#cart" do
  assert_select "table" do
    assert_select "tr", :count => 3
    assert_select "tr.total-line td:last-of-type", "$57.70"
  end
end

3
p200 简单选择器
p201 选择器链

4.
集成测试
ruby script\generate integration_test user_stories




评论
发表评论

您还没有登录,请登录后发表评论

open2ye
搜索本博客
我的相册
Ac44ad89-992f-34f7-973c-60b25a6ddc0c-thumb
action_auth
共 26 张
最近加入圈子
存档
最新评论