http://wiki.github.com/dchelimsky/rspec/configgem-for-rails
http://swachian.iteye.com/blog/163202
http://rspec.info/documentation/
http://hideto.iteye.com/blog/126583
http://github.com/jimweirich/flexmock/tree/master
http://flexmock.rubyforge.org/
require 'flexmock/test_unit'
require 'spec'
Spec::Runner.configure do |config|
config.mock_with :flexmock
end
describe "Using FlexMock with RSpec" do
it "should be able to create a mock" do
m = flexmock(:foo => :bar)
m.foo.should === :bar
end
end
require 'machine'
describe Machine do
before :each do
@machine = Machine.new
end
it "should initially have a state of :initial" do
@machine.state.should == :initial
end
end
describe Account do
context "transfering money" do
it "deposits transfer amount to the other account" do
source = Account.new(50, :USD)
target = mock('target account')
target.should_receive(:deposit).with(Money.new(5, :USD))
source.transfer(5, :USD).to(target)
end
it "reduces its balance by the transfer amount" do
source = Account.new(50, :USD)
target = stub('target account')
source.transfer(5, :USD).to(target)
source.balance.should == Money.new(45, :USD)
end
end
end
$ spec spec/account_spec.rb --format nested
Account
transfering money
deposits transfer amount to the other account
reduces its balance by the transfer amount
Scenario: stub in before
Given the following spec:
"""
describe "a stub in before" do
before(:each) do
@messenger = mock('messenger').as_null_object
end
it "a" do
@messenger.should_receive(:foo).with('first')
@messenger.foo('second')
@messenger.foo('third')
end
end
"""
When I run it with the spec command --format nested
Then the stdout should match "expected :foo with (\"first\") but received it with ([\"second\"], [\"third\"])"
分享到:
相关推荐
RSpec和Minitest匹配器来预防N 1查询问题
rspec_api_documentation, 从RSpec自动生成API文档 RSpec Doc为你的Rails API生成漂亮的。查看一个示例文件。更改请查看维基以了解最新的更改。安装将rspec_api_documentation添加到你的文件gem 'rspec_a
rspec出入门者学习理解,介绍的非常的详细、清楚; 欢迎下载学习~
原版The RSpec Book并附有源码
RSpec.Essentials 英文
rspec 下载请注意:英文文档
rspec-api-blueprint-formatter, 从RSpec测试自动生成API文档 ! RSpec APIBlueprint格式化程序从RSpec测试自动生成API文档 !像这样it 'retrievs the patients medications' do retrieve_medications
rspec-collection_matchers, 集合基数匹配器,从rspec期望中提取 RSpec::CollectionMatchers RSpec::CollectionMatchers 让你在一个例子中表达一个对象集合的预期结果。expect(account.shopping_cart).to have_
rspec-core 是 RSpec 运行和格式化工具。rspec-core 提供一个框架,用来书写你的代码应该怎样表现的可执行案例;以及一个 rspec 命令工具来限制哪些案例可以运行,调整输出格式。 标签:rspec
使用RSpec 测试Rails 程序.pdf
jruby-1.5.5+OperaWatir+RSpec
使用RSpec测试Rails程序。本书基于Rails 4.1,使用完整应用 来演示TDD的流程。
rspec_junit_formatter, RSpec结果格式化为你的CI可以读取的JUnit RSpec JUnit格式化程序 RSpec 2 & 3结果, Jenkins可以读取。 可能还有其他的CI服务。灵感来自于的工作,在的RSpec格式化程序在对 Reporter的失望...
rspec 是目前bdd測試的使用工具,很適合描述測試的內容
rspec-given, RSpec规范的Given/When/Then 关键字 用于RSpec和Minitest主机的 Given/When/Then 覆盖给定的rspec,给定的minitest,以及给定的内核,版本 3.5.3 。给定的rspec和minitest是你喜爱的测试框架的扩展,...
ruby on rails 相关lib 其中包含:rspec flexmock acts_as_taggable-2.0.2 widgets acts_as_list classic_pagination
ruby(rails)单元测试相关的gem,rspec、cucumeber。BDD
这是介绍BDD开发推荐的图书,今年3月份出的,作者基本已经完成了全部的内容了.
rspec-2.x 是一个 meta-gem,依赖于其他组件:rspec-core, rspec-expectations 和 rspec-mocks 。每个组件都可以使用 gem 命令独立安装和运行。 标签:rspec