浏览 2164 次
锁定老帖子 主题:ruby rspec mock study
精华帖 (0) :: 良好帖 (0) :: 新手帖 (3) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2010-01-03
describe "Mocker" do it "should be able to call mock()" do mock = mock("poke me")#创建一个mock对象 mock.should_receive(:poke).once.with(1,2,3)#测试这个对象是否会接收一次poke方法 mock.poke(1,2,3) #test the arg type mock.should_receive(:msg).with(an_instance_of(Fixnum)) mock.msg(2) end #测试mock对象接收方法的顺序 it "should fail when messages are received out of order" do mock = mock("one two three") mock.should_receive(:one).ordered mock.should_receive(:two).ordered mock.should_receive(:three).ordered mock.one mock.two mock.three end end 之后运行 rspc file_name 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |