`
open2ye
  • 浏览: 98520 次
  • 性别: Icon_minigender_1
  • 来自: 温州
社区版块
存档分类
最新评论

读 Agile Web Development with Rails Second Edition 读书笔记 (四)

阅读更多
单元测试中 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




分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics