今天重新在depot运行测试,用静态测试数据测试商品标题的唯一性,发现有个断言过不去:
assert_equal I18n.translate('activerecord.errors.messages.taken'), product.errors[:title]
错误信息:
1) Failure: test_product_is_not_valid_without_a_unique_title_-_i18n(ProductTest) [E:/works/rubyaptana/rails/test/unit/product_test.rb:67]: <"has already been taken"> expected but was <["has already been taken"]>. 5 tests, 24 assertions, 1 failures, 0 errors, 0 skips
后面发现在是因为没有照Agile Web Development with Rails Fourth Edition书上说的写。product.errors[:title]后还有join("; ")
看日志应该是一个字符串,和一个只有一个字符串元素的数组的区别。
经乱试,发现两种方式都可以通过:
1.
assert_equal I18n.translate('activerecord.errors.messages.taken'), product.errors[:title].join("")
2.
assert_equal I18n.translate(['activerecord.errors.messages.taken']), product.errors[:title]
product_test.rb的测试方法是这样的:
test "product is not valid without a unique title - i18n" do product = Product.new(title: products(:ruby).title, description: "yyy", price: 1, image_url: "fred.gif") assert product.invalid? assert_equal I18n.translate(['activerecord.errors.messages.taken']), product.errors[:title] #assert_equal I18n.translate('activerecord.errors.messages.taken'), product.errors[:title].join("") end
相关推荐
assert_param-转载
The DFM Programming Environment is one of the many unique concepts of the Genesis 2000 system. Unlike any existing tool, the DFM Programming Environment (DFMPE) enables any user with elementary ...
ok { 1 + 1 } == 2 # same as assert_equal 2, 1+1 ok { 1 + 1 } > 1 # same as assert_operator 1+1, :>, 1 ok { '123' } =~ / \d +/ # same as assert_match /\d+/, '123' ok { [ ] } . kind_of? ( Array ) # ...
资源分类:Python库 所属语言:Python 资源全名:pytest_cache_assert-1.1.1.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
STM32中assert_param的使用,综合网上多种说法,看完不一样的感觉。
本文是关于assert_param的疑惑。
assert_matches 提供一个... 要包含在您的项目中,仅当编译测试时,才将以下内容添加到您的Cargo.toml中: [ dev-dependencies ]assert_matches = " 1.5 " 并将以下内容添加到您的板条箱根目录中: #[cfg(test)] #[m
2.3.2. 使用声明(Assert)来编写条件性的 ACL 规则 3. Zend_Auth 3.1. 简介 3.1.1. 适配器 3.1.2. 结果 3.1.3. 身份的持久(Persistence) 3.1.3.1. 在PHP Session 中的缺省持久(Persistence) 3.1.3.2. 实现...
合约帮手 该模块提供了一种在函数中...assert_equal 6 , Foo . new . foo ( 2 , 3 ) assert_equal false , Foo . new . foo ( 2 , "3" ) 当包含Contract模块时,方法contract和verify变得可用。 class Bar inclu
parse_matlab\util\assert.m parse_matlab\util\printSkel.m parse_matlab\util\sampleWithR.m parse_matlab\util\isum.m parse_matlab\util\buildHistExps.m parse_matlab\util\local_sum_zero.m parse_...
junit.framework.Assert.class junit.framework.AssertionFailedError.class junit.framework.ComparisonCompactor.class junit.framework.ComparisonFailure.class junit.framework.JUnit4TestAdapter.class junit....
void CMyView::OnInitialUpdate() { CView::OnInitialUpdate(); BITMAP bm; // Windows BITMAP data structure; see Win32 help m_pBitmap[0].LoadBitmap(IDB_BITMAP1);... ASSERT(nTimer!=0); }
对于开始学vc的人,对于assert,assert_valid,verify,trace的宏感到很奇怪,总是觉得很难掌握似的,其实这些主要是没有理清楚他们各自宏之间深层次的意义。
提供对ASSERT_REACHED和ASSERT_REACHED_BEGIN / END的访问,可以按以下方式使用: # include < iostream># include " assert_reached.h "ASSERT_REACHED_BEGIN (fooGuard)void foo( bool a, bool b) { if (a) { ...
01_为什么要进行接口测试、02_认识测试对象、03_postman、04_postman_and_newman、05_鉴权、06_python_http、07_assert、08_unittest、09_test_get、10_test_post11_start_mock_server、12_implement_get..............
assert_eq!(sp.intern(“ hello”),Ok(0)); assert_eq!(sp.intern(“ world”),Ok(1)); assert_eq!(sp.intern(“ hello”),Ok(0)); assert_eq!(sp.resolve(1),Ok(“ world”))); /...
is_equal_to ( 3 ) assert_that ( 'foobar' ). is_length ( 6 ). starts_with ( 'foo' ). ends_with ( 'bar' ) assert_that ([ 'a' , 'b' , 'c' ]). contains ( 'a' ). does_not_contain ( 'x' ) 当然, assertpy最...
write /sys/module/printk/parameters/console_suspend N write /proc/sys/kernel/printk 0 on fs # UDISK would be mounted as data partition when multiple user enabled. #format_userdata /dev/block/by-...
用法使用tinystr :: {TinyStr4,TinyStr8,TinyStr16}; fn main(){让我们tinystr tinystr是一个小的纯ASCII的有界长度字符串表示形式。 用法使用tinystr :: {TinyStr4,TinyStr8,TinyStr16}; fn main(){让s1:...