就是assert包含满足正则表达式
看rspec book上说可以这么写:
发现不好用
[img]http://dl.iteye.com/upload/attachment/233321/33ea5aa4-1951-32d8-b999-fc5fb3421bf8.jpg[/img]
然后改成这样就对了
看rspec book上说可以这么写:
result.should match(/this expression/)
result.should =~ /this expression/
statement.should =~ /Total Due: \$37\.42/m
发现不好用
[img]http://dl.iteye.com/upload/attachment/233321/33ea5aa4-1951-32d8-b999-fc5fb3421bf8.jpg[/img]
然后改成这样就对了
Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
regexp = Regexp.new(regexp)
if defined?(Spec::Rails::Matchers)
response.should contain(regexp)
else
assert_match(regexp, response_body)
end
end