1. Describe block
describe "describes" do
before(:each) do
this will execute every time
end
it “it describes” do
should
should_not
end
end
2. Should and should_not method
receiver.should(matcher) # the simplest example
# Passes if matcher.matches?(receiver)
receiver.should == expected #any value
# Passes if (receiver == expected)
receiver.should === expected #any value
# Passes if (receiver === expected)
receiver.should =~ regexp
# Passes if (receiver =~ regexp)
alse can use
target.should be_true
target.should be_false
target.should be_nil
target.should_not be_nil
3.should be_a_kind_of(Fixnum)
3.should be_an_instance_of(Fixnum)
{:foo => “foo”}.should have_key(:foo)
[1, 2, 3].should include(1)
[1, 2, 3].should have(3).items
3. Shared Behaviors
• before(:all)
• before(:each)
• after(:each)
• after(:all)
describe “people in general”
before(:each) do
puts “shared before()”
end
after(:each) do
puts “shared after()”
end
...
end
describe Teacher do
before(:each) do
puts “teacher before()”
@person = Teacher.new(“Ms. Smith”, 30, 50000)
end
after(:each) do
puts “teacher after()”
end
it_should_behave_like “people in general”
...
end
it_should_behave_like “people in general” can shared methods in people in general. Cool! 4. RSpec’s Mocks and Stubs
Mock Objects
echo.should_receive(:sound).with(“hey”).and_return(“hey”)
Stub Objects
yodeler = stub(‘yodeler’, :yodels? => true)
5. Running Specs
$ spec spec/models/credit_card_spec.rb
$ spec -fs spec/models/credit_card_spec.rb
$ spec -fr spec/models/authorization_spec.rb
6. The RSpec on Rails Plugin
$ script/generate rspec
$ script/generate rspec_model Schedule name:string
分享到:
相关推荐
《Schaum's Outline of Advanced Calculus, Third Edition》是一本由Robert Wrede博士与Murray R. Spiegel博士共同编著的高等微积分教材。该书作为Schaum’s Outline系列的一部分,自1963年第一版出版以来,在全球...
最新版本,612 practice problems with step by step solutions ; concise explanatation of all course concept
《Schaum's Outline of Probability and Statistics, Third Edition》是一本深入浅出讲解概率与统计学原理的经典教材,由Murray R. Spiegel博士、John J. Schiller博士以及R. Alu Srinivasan博士共同编著。本书旨在...
Schaum's Outline of English Grammar
电磁场理论习题集 McGraw-Hill Schaum's Outline of Electromagnetics
根据给定文件的信息,我们可以提炼出以下关于《Schaum's Outline of Programming with C 2nd Ed》的重要知识点: ### 书籍概览 《Schaum's Outline of Programming with C 2nd Ed》是一本专注于C语言编程理论与...
《Schaum’s Outline of Mathematica 2nd Edition》是一本专门为学习Mathematica软件而编写的指导书籍,旨在帮助读者深入理解和掌握这款强大的数学计算工具。Mathematica是由Wolfram Research公司开发的一个交互式...
### 关于《Schaum's Outline of Partial Differential Equations》的知识点详解 #### 一、教材概述 《Schaum's Outline of Partial Differential Equations》是一本针对偏微分方程(Partial Differential ...
《Schaum's Outline of Advanced Calculus 2nd Edt》是一本卓越的微积分教材,由Robert Wrede和Murray R. Spiegel两位数学专家共同编写。这本书是Schaum's Outline系列的一部分,该系列以其深入浅出的理论解释和丰富...
**Schaum's Outline of College Physics** 是一本广泛使用的物理教材,适用于大学物理入门课程。该课程通常被称为“一般物理”或“大学物理”,它通常是为期两个学期的深入调查课程,涵盖经典物理学的主要主题,并在...
Outline-Client上网用,PC端windows使用
《Schaum's Outline of Data Structures with Java》第二版是由John R. Hubbard教授编写的权威指南。本书旨在帮助读者掌握最新的Java语言特性及其在数据结构中的应用。作为全球发展最快、最受欢迎的编程语言之一,...
capabilities of Mathematica. As this is a book designed for first-time users at the undergraduate level, I have included those commands and options that are most commonly used in algebra, trigonometry...
在Cadence Allegro 17.2版本中,设计者们遇到了一个显著的变化,那就是设计大纲(Design Outline)的使用方式。以往版本中,设计师通常使用Outline层来定义电路板的外观,但在17.2版中,Cadence推荐使用Design ...
国外关于数字通信与模拟通信的经典教材,有兴趣的下
Outline-Client,windows版
《Schaum精讲:Java数据结构(第二版)》 英文PDF
《Unity游戏开发:高效性能描边插件Easy Performant Outline详解》 在Unity游戏开发中,视觉效果的呈现是至关重要的。"Easy Performant Outline"是一款专为Unity设计的高性能描边插件,旨在为2D和3D场景提供高质量...
Outline Manager是一款专为管理和组织大纲内容而设计的软件,它在IT行业中被广泛用于项目规划、文档编写、学习笔记和思维导图的创建。这款工具的亮点在于其与Outline服务器端的集成,允许用户在云端存储和同步他们的...