单元测试中 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
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
发表评论
- 浏览: 9589 次
- 性别:

- 来自: 温州

- 详细资料
搜索本博客
我的相册
action_auth
共 26 张
共 26 张
最近加入圈子
链接
最新评论
-
ruby 又一BUG 折磨了我很 ...
放这里记一下sudo apt-get install openssh-clien ...
-- by open2ye -
rails 的测试的 bug 当你 ...
还有一个可能造成这个问题的原因是rails test的transactional ...
-- by iamawalrus -
rails 的测试的 bug 当你 ...
gigix 写道 干嘛不放在before_save呢? 例如Part 在 be ...
-- by open2ye -
rails 的测试的 bug 当你 ...
iamawalrus 写道 检查test环境的db以及对应的table是否和de ...
-- by open2ye -
rails 的测试的 bug 当你 ...
open2ye 写道这个需求很普遍 比如一个是零件表, 另一个是零件的创建日志 ...
-- by iamawalrus






评论排行榜