下面是RSpec测试的一些基础语法,这些都是会运行通过的测试例:
Strings:
'foo'.should == 'foo'
'foo'.should === 'foo'
'foo'.should_not equal('foo')
''.should be_empty
'foo with bar'.should include('with')
'http://fr.ivolo.us'.should match(/http:\/\/.+/i)
nil.should be_nil
Numbers:
100.should < 200
200.should >= 100
(200 - 100).should == 100
100.should be_close(80,21)
Arrays:
[1,2,3].should have(3).items
[].should be_empty
[1,2,3].should include(2)
Hashes:
{}.should be_empty
{:post => {:title => 'test'}}.should have_key(:post)
{:post => {:title => 'test'}}.should_not have_key(:title)
false.should be_false
true.should be_true
Records:
@post.should be_instance_of(Post)
@post.should respond_to(:title)
分享到:
相关推荐
原版The RSpec Book并附有源码
rspec出入门者学习理解,介绍的非常的详细、清楚; 欢迎下载学习~
rspec_api_documentation, 从RSpec自动生成API文档 RSpec Doc为你的Rails API生成漂亮的。查看一个示例文件。更改请查看维基以了解最新的更改。安装将rspec_api_documentation添加到你的文件gem 'rspec_a
rspec 下载请注意:英文文档
请查看以下文章,了解新的RSpec语法和RSpec 3中的更改:如果要在升级到RSpec 3的过程中使用Transpec,请阅读RSpec官方指南:例子这是一个示例规范: describe Account do subject ( :account ) { Account ....
jruby-1.5.5+OperaWatir+RSpec
使用RSpec 测试Rails 程序.pdf
rspec-api-blueprint-formatter, 从RSpec测试自动生成API文档 ! RSpec APIBlueprint格式化程序从RSpec测试自动生成API文档 !像这样it 'retrievs the patients medications' do retrieve_medications
使用RSpec测试Rails程序。本书基于Rails 4.1,使用完整应用 来演示TDD的流程。
rspec-collection_matchers, 集合基数匹配器,从rspec期望中提取 RSpec::CollectionMatchers RSpec::CollectionMatchers 让你在一个例子中表达一个对象集合的预期结果。expect(account.shopping_cart).to have_
rspec 是目前bdd測試的使用工具,很適合描述測試的內容
RSpec.Essentials 英文
ruby(rails)单元测试相关的gem,rspec、cucumeber。BDD
rspec_junit_formatter, RSpec结果格式化为你的CI可以读取的JUnit RSpec JUnit格式化程序 RSpec 2 & 3结果, Jenkins可以读取。 可能还有其他的CI服务。灵感来自于的工作,在的RSpec格式化程序在对 Reporter的失望...
RSpec和Minitest匹配器来预防N 1查询问题
Api-rspec_api_documentation.zip,从rspecrspec api doc generator自动生成api文档,一个api可以被认为是多个软件设备之间通信的指导手册。例如,api可用于web应用程序之间的数据库通信。通过提取实现并将数据放弃到...
RSpec :: Wait允许您使用已经知道和喜欢的RSpec语法糖来等待声明通过。 RSpec :: Wait将继续尝试,直到您的断言通过或超时为止。 例子 RSpec :: Wait的wait_for断言几乎替代了RSpec的expect断言。 主要区别在于...
在他们下载的chm始终打不开或有问题。 ... 使用Cucumber+Rspec玩转BDD(1)——用户注册 使用Cucumber+Rspec玩转BDD(2)——邮件激活 ...使用Cucumber+Rspec玩转BDD(3)——用户...使用Cucumber+Rspec玩转BDD(7)——测试重构
db-query-matchers, 用于数据库查询的RSpec匹配器 db-query-matchers 用于数据库查询的RSpec匹配器。安装在你的应用程序中添加这一行,最好在你的test 组中:gem 'db-query-matchers'然后执行:bundle